Exemple #1
0
    def GET(self, request, user_id):
        poster = get_object_or_404(Poster, pk=user_id)

        ctx = {
            'poster': poster,
            'bans': poster.bans.order_by('-start_date')
        }

        if poster.pk == request.user.pk:
            ctx['settings_form'] = self._base_settings_form(poster)
            ctx['avatar_form'] = self._base_avatar_form(poster)

        ip_acl = AccessControlList.get_acl('VIEW_IPS')
        if ip_acl.is_poster_authorized(request.user):
            ip_distr = (poster.post_set
                .values('posted_from')
                .annotate(num_posts=Count('id'))
                .order_by('-num_posts'))

            ctx['ip_distr'] = ip_distr[:10]
            ctx['ip_distr_remaining'] = max(ip_distr.count() - 10, 0)

        HookManager.add_ctx_for_hook(ctx, 'user_profile_stats', poster)

        return render(request, 'user_profile.html', ctx)
Exemple #2
0
    def _process_settings_form(self, request, poster):
        form = forms.UserSettingsForm(request.POST)

        if form.is_valid():
            form.save(poster)
            return HttpResponseRedirect(poster.get_url())

        else:
            ctx = {
                'poster': poster,
                'settings_form': form,
                'avatar_form': self._base_avatar_form(poster)
            }

            HookManager.add_ctx_for_hook(ctx, 'user_profile_stats', poster)

            return render(request, 'user_profile.html', ctx)
Exemple #3
0
from ISS.hooks import HookManager, Catch

def profile_catch_generator(poster):
    return {
        'poster': poster
    }

HookManager.register_catch(Catch(
    'user_profile_stats',
    profile_catch_generator,
    'taboo/user_profile_stats.html'))