Esempio n. 1
0
    def post(self, request, *args, **kwargs):
        reason = CsrfViewMiddleware().process_view(request, None, (), {})
        if reason:
            raise PermissionDenied

        person = get_or_create_person(request)

        form = ResendEmailVerificationForm(request.POST)
        if form.is_valid():
            email_object, created = get_email_object(person)
            email_object.send_confirmation()

        return super(GroupStatsView, self).get(request, *args, **kwargs)
Esempio n. 2
0
    def get_context_data(self, **kwargs):
        context = \
            super(GroupStatsView, self).get_context_data(**kwargs)

        group = context['group']

        context['x_title'] = _('Group Leaderboard: {0}').format(group)
        context['x_description'] = _("Leaderboard for members of {0}.").format(
            group)

        language = get_current_language(self.request)

        people = Person.objects.all()

        valid_members = people
        valid_members = get_valid_group_members(group, valid_members)

        invalid_members = people
        invalid_members = get_invalid_group_members(group, invalid_members)

        # people = people\
        #     .filter(recording__sentence__language=language)

        # score, count = get_competition_group_score(group)
        num_recordings = 0
        if valid_members:
            for member in valid_members:
                recordings = filter_qs_for_competition(
                    Recording.objects.filter(person=member))
                member.num_recordings = recordings.count()

        if invalid_members:
            invalid_members = invalid_members\
                .annotate(num_groups=Count('groups', distinct=True))

            for member in invalid_members:
                recordings = filter_qs_for_competition(
                    Recording.objects.filter(person=member))
                member.num_recordings = recordings.count()
                member.verified = email_verified(member)

        form = ResendEmailVerificationForm()

        group.duration_hours = group.duration / 60 / 60

        context['group'] = group
        context['score'] = group.score
        context['form'] = form
        context['people'] = people.filter(groups=group)
        context['valid_members'] = valid_members
        context['invalid_members'] = invalid_members

        return context