def handle(*args, **opts):
        from programme.models import Programme
        from core.models import Event
        from badges.models import Badge

        for event_slug in args[1:]:
            event = Event.objects.get(slug=event_slug)

            for programme in Programme.objects.filter(category__event=event):
                for person in programme.organizers.all():
                    print person
                    Badge.get_or_create(event=event, person=person)
예제 #2
0
파일: models.py 프로젝트: wyrmiyu/kompassi
    def apply_state_create_badges(self):
        if 'badges' not in settings.INSTALLED_APPS:
            return

        if self.event.badges_event_meta is None:
            return

        if not self.is_accepted:
            return

        # TODO revoke badge if one exists but shouldn't

        from badges.models import Badge
        Badge.get_or_create(event=self.event, person=self.person)
    def handle(*args, **opts):
        from programme.models import Programme
        from core.models import Event
        from badges.models import Badge

        for event_slug in args[1:]:
            event = Event.objects.get(slug=event_slug)

            for programme in Programme.objects.filter(category__event=event).exclude(state__in=['rejected', 'cancelled']):
                for person in programme.organizers.all():
                    try:
                        Badge.get_or_create(event=event, person=person)
                        print person
                    except Badge.MultipleObjectsReturned:
                        print u'WARNING: Multiple badges for', person
예제 #4
0
파일: signup.py 프로젝트: akx/kompassi
    def apply_state_create_badges(self):
        if 'badges' not in settings.INSTALLED_APPS:
            return

        if self.event.badges_event_meta is None:
            return

        if not self.is_accepted:
            return

        # TODO revoke badge if one exists but shouldn't

        from badges.models import Badge
        badge, created = Badge.get_or_create(event=self.event, person=self.person)

        # Update job title if it is not too late
        if (
            # Just a short-circuit optimization – the job title cannot change if the badge was just created
            not created

            # Don't touch badges of other apps (for example, programme)
            and badge.personnel_class.app_label == 'labour'

            # Don't touch badges that are already printed (XXX should revoke and re-create)
            and badge.batch is None

            # Finally, check if the job title needs update
            and badge.job_title != signup.job_title
        ):
            badge.job_title = signup.job_title
            badge.save()