Пример #1
0
    def __init__(self, *args, **kwargs):
        
        if kwargs.has_key('user'):
            self.user = kwargs.pop('user')
        else:
            from share.middleware import share
            self.user = share.get_display_user()
        
        pw = kwargs.pop('plane_widget', None)
        
        super(PopupFlightForm, self).__init__(*args, **kwargs)

        self.fields['date'].widget = widgets.AdminDateWidget()
        
        self.fields['plane'].queryset = \
                 Plane.objects\
                      .user(self.user)\
                      .exclude(retired=True)\
                      .select_related()\
                      .annotate(fd=Max('flight__date'))\
                      .order_by('-fd')
        
        if pw:             
            self.fields['plane'].widget = pw
            
        self.fields['plane'].user = self.user
Пример #2
0
    def __init__(self, *args, **kwargs):

        if kwargs.has_key('user'):
            self.user = kwargs.pop('user')
        else:
            from share.middleware import share
            self.user = share.get_display_user()

        pw = kwargs.pop('plane_widget', None)

        super(PopupFlightForm, self).__init__(*args, **kwargs)

        self.fields['date'].widget = widgets.AdminDateWidget()

        self.fields['plane'].queryset = \
                 Plane.objects\
                      .user(self.user)\
                      .exclude(retired=True)\
                      .select_related()\
                      .annotate(fd=Max('flight__date'))\
                      .order_by('-fd')

        if pw:
            self.fields['plane'].widget = pw

        self.fields['plane'].user = self.user
Пример #3
0
 def from_string(cls, raw_route_string, user=None, date=None):
     """
     Create a route object from a raw string
     """
     
     from make_route import MakeRoute
     
     if not user:
         # for legacy only
         user = share.get_display_user()
         
     return MakeRoute(raw_route_string, user=user, date=date).get_route()
Пример #4
0
    def from_string(cls, raw_route_string, user=None, date=None):
        """
        Create a route object from a raw string
        """

        from make_route import MakeRoute

        if not user:
            # for legacy only
            user = share.get_display_user()

        return MakeRoute(raw_route_string, user=user, date=date).get_route()
Пример #5
0
    def save(self, *args, **kwargs):
        try:
            getattr(self, "user", None).username
        except:
            #user is not set, we now must get the current logged in user
            from share.middleware import share
            self.user = share.get_display_user()

        no_badges = kwargs.pop('no_badges', False)

        super(Flight,self).save(*args, **kwargs)

        if (not no_badges) and settings.BADGES_ENABLE:
            from badges.models import award_badges
            print "doing badge calc"
            award_badges(self)
Пример #6
0
    def save(self, *args, **kwargs):
        try:
            getattr(self, "user", None).username
        except:
            #user is not set, we now must get the current logged in user
            from share.middleware import share
            self.user = share.get_display_user()

        no_badges = kwargs.pop('no_badges', False)

        super(Flight, self).save(*args, **kwargs)

        if (not no_badges) and settings.BADGES_ENABLE:
            from badges.models import award_badges
            print "doing badge calc"
            award_badges(self)