示例#1
0
    def decorator(request, *args, **kwargs):
        User = get_user_model()

        relations = ('rank', 'online_tracker', 'ban_cache')
        queryset = User.objects.select_related(*relations)
        profile = get_object_or_404(queryset, id=kwargs.pop('user_id'))

        validate_slug(profile, kwargs.pop('user_slug'))
        kwargs['profile'] = profile

        add_acl(request.user, profile)

        if profile.acl_['can_follow']:
            profile.is_followed = request.user.is_following(profile)
        else:
            profile.is_followed = False

        if profile.acl_['can_block'] and request.user.is_authenticated():
            profile.is_blocked = request.user.is_blocking(profile)
        else:
            profile.is_blocked = False

        if request.user.is_authenticated and request.method == "GET":
            read_user_notification(request.user, "profile_%s" % profile.pk)

        return f(request, *args, **kwargs)
示例#2
0
    def decorator(request, *args, **kwargs):
        User = get_user_model()

        relations = ('rank', 'online_tracker', 'ban_cache')
        queryset = User.objects.select_related(*relations)
        profile = get_object_or_404(queryset, id=kwargs.pop('user_id'))

        validate_slug(profile, kwargs.pop('user_slug'))
        kwargs['profile'] = profile

        add_acl(request.user, profile)

        if profile.acl_['can_follow']:
            profile.is_followed = request.user.is_following(profile)
        else:
            profile.is_followed = False

        if profile.acl_['can_block'] and request.user.is_authenticated():
            profile.is_blocked = request.user.is_blocking(profile)
        else:
            profile.is_blocked = False

        if request.user.is_authenticated and request.method == "GET":
            read_user_notification(request.user, "profile_%s" % profile.pk)

        return f(request, *args, **kwargs)
示例#3
0
文件: usercp.py 项目: jinchaoh/Misago
def edit_signature(request):
    if not request.user.acl['can_have_signature']:
        raise Http404()

    if request.method == "GET":
        read_user_notification(request.user,
                               'usercp_signature_%s' % request.user.pk)

    form = EditSignatureForm(instance=request.user)
    if not request.user.is_signature_locked and request.method == 'POST':
        form = EditSignatureForm(request.POST, instance=request.user)
        if form.is_valid():
            set_user_signature(
                request, request.user, form.cleaned_data['signature'])
            request.user.save(update_fields=[
                'signature', 'signature_parsed', 'signature_checksum'
            ])

            if form.cleaned_data['signature']:
                messages.success(request, _("Your signature has been edited."))
            else:
                message = _("Your signature has been cleared.")
                messages.success(request, message)
            return redirect('misago:usercp_edit_signature')

    acl = request.user.acl
    editor = Editor(form['signature'],
                    allow_blocks=acl['allow_signature_blocks'],
                    allow_links=acl['allow_signature_links'],
                    allow_images=acl['allow_signature_images'])
    return render(request, 'misago/usercp/edit_signature.html',
                  {'form': form, 'editor': editor})
示例#4
0
        def decorator(*args, **kwargs):
            request = args[0]
            user = request.user
            profile = kwargs.get('profile')

            if user.is_authenticated and request.method == "GET":
                read_user_notification(user, trigger % profile.pk)

            return f(*args, **kwargs)
示例#5
0
        def decorator(*args, **kwargs):
            request = args[0]
            user = request.user
            profile = kwargs.get('profile')

            if user.is_authenticated and request.method == "GET":
                read_user_notification(user, trigger % profile.pk)

            return f(*args, **kwargs)
示例#6
0
文件: usercp.py 项目: jinchaoh/Misago
 def decorator(request, *args, **kwargs):
     if request.method == "GET":
         read_user_notification(request.user,
                                'usercp_avatar_%s' % request.user.pk)
     if request.user.is_avatar_locked:
         message = _("Your avatar is locked and can't be changed.")
         messages.info(request, message)
         return redirect('misago:usercp_change_avatar')
     else:
         return f(request, *args, **kwargs)