Example #1
0
 def get_object(self, request ):
     #TODO: sjekk request.user
     params =  request.GET
     include_published = params.has_key('published')
     from_date = params['from_date'] + "000000" if params.has_key('from_date') else None
     to_date = params['to_date'] + "000000" if params.has_key('to_date') else None
     if request.user.is_authenticated():
         return archive.get_latest_archive_items(from_date=from_date, to_date=to_date, include_published=include_published)
     else:
         return list()
Example #2
0
 def __init__(self, *args, **kwargs):
     choices = map(lambda v:(v.id, v.title), archive.get_latest_archive_items(n=50, include_published=False))
     if kwargs.has_key('instance'):
         video = kwargs['instance']
         choices.append((video.archive_id, video.title))
     choices.sort(key=lambda t:int(t[0]))
     choices.reverse()
     #choices.insert(0, ('-1', '---'))
     super(VideoAdminForm, self).__init__(*args, **kwargs)
     self.fields['archive_id'] = VideoSelectField(choices=choices)
Example #3
0
def get_unpublished_archive_items():
    #TODO: denne bør bare filtrere på en "new action" ikke "change"
    latest = map(lambda o:(o.id, o.title), archive.get_latest_archive_items(n=100))
    #latest = filter(lambda o: len(Video.objects.filter(archive_id = o[0])) == 0, latest)
    latest.insert(0, ('',''))
    return latest