<commit_before>from time import strftime

from django.conf.urls.defaults import *

from compsoc.comms.models import Communication,COMMS_TYPE
from compsoc.shortcuts import current_year,get
from compsoc.events.models import future_events

def from_date(date):
    return (date.year,strftime("%b",(0,date.month,0,0,0,0,0,0,0)))

def lookup(item_type):
    data = Communication.objects.filter(type=item_type).order_by('-date')
    store = {}
    for comm in data:
        store[from_date(comm.date)] = True
    return store.keys()

def get_dict(item_type,paginate=True,intro=False):
    data = Communication.objects.filter(type=item_type).order_by('-date')
    info_dict = {
        'queryset':data,
        'template_name':'comms/list.html',
        'extra_context':{
            'type':get(COMMS_TYPE,item_type).lower(),
            'dates':lambda: lookup(item_type),
            'future':future_events(),
            'intro':intro,
        },
    }
    if paginate:    info_dict['paginate_by'] = 10
    else:           info_dict['date_field'] = 'date'
    return info_dict

urlpatterns = patterns('django.views.generic.list_detail',
    (r'^$','object_list',get_dict('N', intro=True)),
    (r'^news/(?P<page>[0-9]+)/$','object_list',get_dict('N')),
    (r'^minutes/(?P<page>[0-9]+)/$','object_list',get_dict('M')),
    (r'^newsletters/(?P<page>[0-9]+)/$','object_list',get_dict('NL')),
    (r'^details/(?P<object_id>\d+)/$', 'object_detail',{
        'queryset':Communication.objects.all(),
        'extra_context':{
            'future':future_events(),
        },
    }),

) + patterns('django.views.generic.date_based',
    (r'^monthnews-items/(?P<year>\d{4})/(?P<month>[A-Za-z]{3})/$','archive_month',get_dict('N',False)),
    (r'^monthminutes/(?P<year>\d{4})/(?P<month>[A-Za-z]{3})/$','archive_month',get_dict('M',False)),
    (r'^monthnewsletters/(?P<year>\d{4})/(?P<month>[A-Za-z]{3})/$','archive_month',get_dict('NL',False)),
)<commit_msg>future events queried on pageload<commit_after>from time import strftime

from django.conf.urls.defaults import *

from compsoc.comms.models import Communication,COMMS_TYPE
from compsoc.shortcuts import current_year,get
from compsoc.events.models import future_events

def from_date(date):
    return (date.year,strftime("%b",(0,date.month,0,0,0,0,0,0,0)))

def lookup(item_type):
    data = Communication.objects.filter(type=item_type).order_by('-date')
    store = {}
    for comm in data:
        store[from_date(comm.date)] = True
    return store.keys()

def get_dict(item_type,paginate=True,intro=False):
    data = Communication.objects.filter(type=item_type).order_by('-date')
    info_dict = {
        'queryset':data,
        'template_name':'comms/list.html',
        'extra_context':{
            'type':get(COMMS_TYPE,item_type).lower(),
            'dates':lambda: lookup(item_type),
            'future':lambda: future_events(),
            'intro':intro,
        },
    }
    if paginate:    info_dict['paginate_by'] = 10
    else:           info_dict['date_field'] = 'date'
    return info_dict

urlpatterns = patterns('django.views.generic.list_detail',
    (r'^$','object_list',get_dict('N', intro=True)),
    (r'^news/(?P<page>[0-9]+)/$','object_list',get_dict('N')),
    (r'^minutes/(?P<page>[0-9]+)/$','object_list',get_dict('M')),
    (r'^newsletters/(?P<page>[0-9]+)/$','object_list',get_dict('NL')),
    (r'^details/(?P<object_id>\d+)/$', 'object_detail',{
        'queryset':Communication.objects.all(),
        'extra_context':{
            'future':lambda: future_events(),
        },
    }),

) + patterns('django.views.generic.date_based',
    (r'^monthnews-items/(?P<year>\d{4})/(?P<month>[A-Za-z]{3})/$','archive_month',get_dict('N',False)),
    (r'^monthminutes/(?P<year>\d{4})/(?P<month>[A-Za-z]{3})/$','archive_month',get_dict('M',False)),
    (r'^monthnewsletters/(?P<year>\d{4})/(?P<month>[A-Za-z]{3})/$','archive_month',get_dict('NL',False)),
)
{'fraction_non_alphanumeric': 0.21283095723014256, 'fraction_numerical': 0.01120162932790224, 'mean_word_length': 4.162943495400788, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7168152', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1412, 'n_words': 154}