Conjunto de mudanças 6215 no repositório publico


Ignorar:
Timestamp:
18/04/2012 10:20:40 (9 anos atrás)
Autor:
seocam
Mensagem:

Fazendo merge com https://bitbucket.org/seocam/atu-colab/src/f70c46c4b63d

Localização:
colab/trunk
Arquivos:
3 adicionados
14 editados

Legenda:

Não Modificado
Adicionado
Removido
  • colab/trunk/colab/api/handlers.py

    r6017 r6215  
    88from piston.handler import BaseHandler
    99
     10from colab import solrutils
    1011from colab.super_archives.models import Message, PageHit
    1112
     
    7071        return rc.CREATED
    7172
     73class SearchHandler(BaseHandler):
     74    allowed_methods = ('GET', )
     75
     76    def read(self, request):
     77        query = request.GET.get('q')
     78        page = request.GET.get('p', 1)
     79        results_per_page = request.GET.get('n', 50)
     80        order = request.GET.get('o')
     81
     82        if not query:
     83            return 'Query cannot be empty.'
     84        else:
     85            query = query.encode('utf-8')
     86
     87        try:
     88            n = int(results_per_page)
     89        except ValueError:
     90            n = 10
     91   
     92        if 1 > n > 500:
     93            n = 1
     94       
     95        try:
     96            page = int(page)
     97        except ValueError:
     98            page = 1
     99       
     100        if page < 1:
     101            page = 1
     102
     103        return solrutils.select(query, results_per_page, page, order)
  • colab/trunk/colab/api/urls.py

    r6017 r6215  
    33from piston.resource import Resource
    44
    5 from colab.api.handlers import VoteHandler, CountHandler
     5from colab.api.handlers import VoteHandler, CountHandler, SearchHandler
    66
    77
    88vote_handler = Resource(VoteHandler)
    99count_handler = Resource(CountHandler)
     10search_handler = Resource(SearchHandler)
    1011
    1112urlpatterns = patterns('',
    1213    url(r'message/(?P<message_id>\d+)/vote$', vote_handler),
    1314    url(r'hit/$', count_handler),
     15    url(r'search/$', search_handler),
    1416)
  • colab/trunk/colab/settings.py

    r6208 r6215  
    154154SOLR_SELECT_PATH = '/solr/select'
    155155
    156 SOLR_COLAB_URI = 'http://colab.interlegis.gov.br'
     156SOLR_COLAB_URI = 'http://colab.interlegis.leg.br'
    157157SOLR_BASE_QUERY = """
    158158    ((Type:changeset OR Type:ticket OR Type:wiki OR Type:thread) AND Title:["" TO *])
  • colab/trunk/colab/settings_local-dev.py

    r6126 r6215  
    1515}
    1616
     17SOLR_COLAB_URI = None
     18
    1719# Make this unique, and don't share it with anybody.
    1820SECRET_KEY = ')(jksdfhsjkadfhjkh234ns!8fqu-1186h$vuj'
    1921
    20 import socks
    21 SOCKS_TYPE = socks.PROXY_TYPE_SOCKS5
    22 SOCKS_SERVER = '127.0.0.1'
    23 SOCKS_PORT = 9050
     22#import socks
     23#SOCKS_TYPE = socks.PROXY_TYPE_SOCKS5
     24#SOCKS_SERVER = '127.0.0.1'
     25#SOCKS_PORT = 9050
    2426
  • colab/trunk/colab/solrutils.py

    r6126 r6215  
    6262   
    6363    url = ''
    64     if doc_type in ('ticket', 'wiki', 'changeset'):
     64    if settings.SOLR_COLAB_URI:
    6565        url += settings.SOLR_COLAB_URI
    6666   
  • colab/trunk/colab/super_archives/admin.py

    r6017 r6215  
    44
    55class MessageAdmin(admin.ModelAdmin):
    6     list_filter = ('spam', 'mailinglist', 'received_time', )
     6    list_filter = ('spam', 'thread__mailinglist', 'received_time', )
    77    search_fields = (
    88        'id',
  • colab/trunk/colab/super_archives/management/commands/import_emails.py

    r6017 r6215  
    131131                yield mailinglist_name, msg, index
    132132
    133     def get_thread(self, email):
     133    def get_thread(self, email, mailinglist):
    134134        """Group messages by thread looking for similar subjects"""
    135135       
     
    138138        if thread is None:
    139139            thread = Thread.objects.get_or_create(
    140                 mailinglist=email.mailinglist,
     140                mailinglist=mailinglist,
    141141                subject_token=subject_slug
    142142            )[0]
     
    157157        try:
    158158            # If the message is already at the database don't do anything
    159             Message.objects.get(message_id=email_msg.get('Message-ID'))
     159            message = Message.objects.get(
     160                                        message_id=email_msg.get('Message-ID'))
     161            if message.thread.mailinglist.name != mailinglist.name:
     162                raise ObjectDoesNotExist
    160163        except ObjectDoesNotExist:
    161164            self.create_email(mailinglist, email_msg)
     
    182185            message_id=email_msg.get('Message-ID'),
    183186            from_address=email_addr,
    184             mailinglist=mailinglist,
    185187            subject=subject,
    186188            subject_clean=self.RE_SUBJECT_CLEAN.sub('', subject).strip(),
     
    188190            received_time=email_msg.get_received_datetime(),
    189191        )
    190         email.thread = self.get_thread(email)
     192        email.thread = self.get_thread(email, mailinglist)
    191193        email.save()
    192194
  • colab/trunk/colab/super_archives/models.py

    r6126 r6215  
    195195                                self.from_address.get_full_name(),
    196196                                self.subject_clean)
     197   
     198    @property
     199    def mailinglist(self):
     200        if not self.thread or not self.thread.mailinglist:
     201            return None
     202       
     203        return self.thread.mailinglist
     204
    197205       
    198206    def vote_list(self):
  • colab/trunk/colab/super_archives/queries.py

    r6126 r6215  
    2929def get_first_message_in_thread(mailinglist, thread_token):
    3030    query = get_messages_by_date()
    31     query = query.filter(mailinglist__name=mailinglist)
     31    query = query.filter(thread__mailinglist__name=mailinglist)
    3232    query = query.filter(thread__subject_token=thread_token)[0]
    3333    return query
  • colab/trunk/colab/super_archives/views.py

    r6208 r6215  
    1919   
    2020    msgs_query = msgs_query.filter(thread__subject_token=thread_token)
    21     msgs_query = msgs_query.filter(mailinglist__name=mailinglist)
     21    msgs_query = msgs_query.filter(thread__mailinglist__name=mailinglist)
    2222    emails = msgs_query.exclude(id=first_message.id)
    2323   
  • colab/trunk/colab/templates/base.html

    r6208 r6215  
    138138    <div id="footer" class="span-24 center">
    139139      {% block footer %}
     140        <p><a href="{% url opendata %}"><img src="{{ STATIC_URL }}img/opendata3.png"/></a></p>
    140141        <p>O conteúdo deste site está publicado sob a licença <a
    141142          href="http://creativecommons.org/licenses/by-nc-sa/2.0/br/">Creative
  • colab/trunk/colab/urls.py

    r6208 r6215  
    11from django.conf.urls.defaults import patterns, include, url
     2from django.views.generic.simple import direct_to_template
    23
    34# Uncomment the next two lines to enable the admin:
     
    910
    1011    url(r'^archives/', include('colab.super_archives.urls')),
    11 
     12   
    1213    url(r'^api/', include('colab.api.urls')),
    1314   
    1415    url(r'^rss/', include('colab.rss.urls')),
     16
     17    url(r'open-data/$', direct_to_template, {'template': 'open-data.html'},
     18        name='opendata'),
    1519
    1620    url(r'^user/(?P<username>[\w@+.-]+)/?$',
  • colab/trunk/etc/apache2/sites-available/colab

    r6017 r6215  
    2424        RewriteRule ^/about(.*) http://colab-backend.interlegis.leg.br/about$1 [P]
    2525        RewriteRule ^/prefs(.*) http://colab-backend.interlegis.leg.br/prefs$1 [P]
     26        RewriteRule ^/log(.*) http://colab-backend.interlegis.leg.br/log$1 [P]
    2627        RewriteRule ^/login(.*) http://colab-backend.interlegis.leg.br/login$1 [P]
    2728        RewriteRule ^/logout(.*) http://colab-backend.interlegis.leg.br/logout$1 [P]
  • colab/trunk/setup.py

    r6017 r6215  
    55
    66setup(name='colab',
    7       version='0.1-dev',
     7      version='3.0',
    88      author='Sergio Oliveira',
    99      author_email='seocam@seocam.com',
Note: Veja TracChangeset para ajuda no uso do visualizador de conjunto de mudanças.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.