forked from rc/aircox
		
	admin
This commit is contained in:
		@ -7,7 +7,7 @@ import programs.settings
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class EventList:
 | 
			
		||||
class DiffusionList:
 | 
			
		||||
    type  = None
 | 
			
		||||
    next  = None
 | 
			
		||||
    prev  = None
 | 
			
		||||
@ -22,29 +22,29 @@ class EventList:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def get_queryset (self):
 | 
			
		||||
        events = models.Event.objects;
 | 
			
		||||
        diffusions = models.Diffusion.objects;
 | 
			
		||||
 | 
			
		||||
        if self.next:   events = events.filter( date_end__ge = timezone.now() )
 | 
			
		||||
        elif self.prev: events = events.filter( date_end__le = timezone.now() )
 | 
			
		||||
        else:           events = events.all()
 | 
			
		||||
        if self.next:   diffusions = diffusions.filter( date_end__ge = timezone.now() )
 | 
			
		||||
        elif self.prev: diffusions = diffusions.filter( date_end__le = timezone.now() )
 | 
			
		||||
        else:           diffusions = diffusions.all()
 | 
			
		||||
 | 
			
		||||
        events = events.extra(order_by = ['date'])
 | 
			
		||||
        if self.at:     events = events[self.at:]
 | 
			
		||||
        if self.count:  events = events[:self.count]
 | 
			
		||||
        diffusions = diffusions.extra(order_by = ['date'])
 | 
			
		||||
        if self.at:     diffusions = diffusions[self.at:]
 | 
			
		||||
        if self.count:  diffusions = diffusions[:self.count]
 | 
			
		||||
 | 
			
		||||
        self.events = events
 | 
			
		||||
        self.diffusions = diffusions
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def raw_string():
 | 
			
		||||
        """
 | 
			
		||||
        Return a string with events rendered as raw
 | 
			
		||||
        Return a string with diffusions rendered as raw
 | 
			
		||||
        """
 | 
			
		||||
        res = []
 | 
			
		||||
        for event in events:
 | 
			
		||||
            r = [ dateformat.format(event.date, "Y/m/d H:i:s")
 | 
			
		||||
                , str(event.type)
 | 
			
		||||
                , event.parent.file.path
 | 
			
		||||
                , event.parent.file.url
 | 
			
		||||
        for diffusion in diffusions:
 | 
			
		||||
            r = [ dateformat.format(diffusion.date, "Y/m/d H:i:s")
 | 
			
		||||
                , str(diffusion.type)
 | 
			
		||||
                , diffusion.parent.file.path
 | 
			
		||||
                , diffusion.parent.file.url
 | 
			
		||||
                ]
 | 
			
		||||
 | 
			
		||||
            res.push(' '.join(r))
 | 
			
		||||
@ -56,13 +56,13 @@ class EventList:
 | 
			
		||||
        import json
 | 
			
		||||
 | 
			
		||||
        res = []
 | 
			
		||||
        for event in events:
 | 
			
		||||
        for diffusion in diffusions:
 | 
			
		||||
            r = {
 | 
			
		||||
                  'date': dateformat.format(event.date, "Y/m/d H:i:s")
 | 
			
		||||
                , 'date_end': dateformat.format(event.date_end, "Y/m/d H:i:s")
 | 
			
		||||
                , 'type': str(event.type)
 | 
			
		||||
                , 'file_path': event.parent.file.path
 | 
			
		||||
                , 'file_url': event.parent.file.url
 | 
			
		||||
                  'date': dateformat.format(diffusion.date, "Y/m/d H:i:s")
 | 
			
		||||
                , 'date_end': dateformat.format(diffusion.date_end, "Y/m/d H:i:s")
 | 
			
		||||
                , 'type': str(diffusion.type)
 | 
			
		||||
                , 'file_path': diffusion.parent.file.path
 | 
			
		||||
                , 'file_url': diffusion.parent.file.url
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            res.push(json.dumps(r))
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user