示例#1
0
def user_links(request):
    request.frontend_context.update({
        'REQUEST_ACTIVATION_URL':
        reverse('misago:request_activation'),
        'FORGOTTEN_PASSWORD_URL':
        reverse('misago:forgotten_password'),
        'BANNED_URL':
        reverse('misago:banned'),
        'USERCP_URL':
        reverse('misago:options'),
        'USERS_LIST_URL':
        reverse('misago:users'),
        'AUTH_API':
        reverse('misago:api:auth'),
        'USERS_API':
        reverse('misago:api:user-list'),
        'CAPTCHA_API_URL':
        reverse('misago:api:captcha_question'),
    })

    return {
        'USERCP_URL': usercp.get_default_link(),
        'USERS_LIST_URL': users_list.get_default_link(),
        'USER_PROFILE_URL': user_profile.get_default_link(),
    }
示例#2
0
    def get(self, request, *args, **kwargs):
        profile = self.get_profile(request, kwargs.pop('pk'),
                                   kwargs.pop('slug'))

        return redirect(user_profile.get_default_link(),
                        slug=profile.slug,
                        pk=profile.pk)
示例#3
0
def moderation_return_path(request, user):
    return_path = clean_return_path(request)
    if not return_path:
        return reverse(user_profile.get_default_link(),
                       kwargs={
                           'user_slug': user.slug,
                           'user_id': user.pk
                       })
    return return_path
示例#4
0
 def decorator(request, profile):
     response = f(request, profile.lock())
     if request.is_ajax():
         response['is_error'] = False
         return JsonResponse(response)
     else:
         messages.success(request, response['message'])
         return_path = clean_return_path(request)
         if return_path:
             return redirect(return_path)
         else:
             return redirect(user_profile.get_default_link(),
                             user_slug=profile.slug, user_id=profile.id)
示例#5
0
 def decorator(request, profile):
     response = f(request, profile.lock())
     if request.is_ajax():
         response['is_error'] = False
         return JsonResponse(response)
     else:
         messages.success(request, response['message'])
         return_path = clean_return_path(request)
         if return_path:
             return redirect(return_path)
         else:
             return redirect(user_profile.get_default_link(),
                             user_slug=profile.slug,
                             user_id=profile.id)
示例#6
0
def user_links(request):
    request.frontend_context.update({
        'REQUEST_ACTIVATION_URL': reverse('misago:request_activation'),
        'FORGOTTEN_PASSWORD_URL': reverse('misago:forgotten_password'),

        'BANNED_URL': reverse('misago:banned'),

        'USERCP_URL': reverse('misago:options'),
        'USERS_LIST_URL': reverse('misago:users'),
    })

    return {
        'USERCP_URL': usercp.get_default_link(),
        'USERS_LIST_URL': users_list.get_default_link(),
        'USER_PROFILE_URL': user_profile.get_default_link(),
    }
示例#7
0
def follow_user(request, profile):
    user_locked = request.user.lock()
    profile.lock()

    if request.user.is_following(profile):
        request.user.follows.remove(profile)
        followed = False
    else:
        allow_follow_user(request.user, profile)
        followed = True
        request.user.follows.add(profile)

    if followed:
        message = _("You are now following %(user)s.")
        notify_user(profile,
                    _("%(user)s is now following you."),
                    reverse(user_profile.get_default_link(),
                            kwargs={
                                'user_slug': user_locked.slug,
                                'user_id': user_locked.id
                            }),
                    "profile_%s" % user_locked.pk,
                    formats={'user': user_locked.username},
                    sender=user_locked,
                    update_user=False)
    else:
        message = _("You have stopped following %(user)s.")
    message = message % {'user': profile.username}

    profile.followers = profile.followed_by.count()
    if followed:
        profile.save(update_fields=['followers', 'new_notifications'])
    else:
        profile.save(update_fields=['followers'])

    user_locked.following = user_locked.follows.count()
    user_locked.save(update_fields=['following'])

    if request.is_ajax:
        return {'is_following': followed, 'message': message}
    else:
        messages.success(request, message)
示例#8
0
def follow_user(request, profile):
    user_locked = request.user.lock()
    profile.lock()

    if request.user.is_following(profile):
        request.user.follows.remove(profile)
        followed = False
    else:
        allow_follow_user(request.user, profile)
        followed = True
        request.user.follows.add(profile)

    if followed:
        message = _("You are now following %(user)s.")
        notify_user(profile,
            _("%(user)s is now following you."),
            reverse(user_profile.get_default_link(), kwargs={
                'user_slug': user_locked.slug, 'user_id': user_locked.id
            }),
            "profile_%s" % user_locked.pk,
            formats={'user': user_locked.username},
            sender=user_locked,
            update_user=False)
    else:
        message = _("You have stopped following %(user)s.")
    message = message % {'user': profile.username}

    profile.followers = profile.followed_by.count()
    if followed:
        profile.save(update_fields=['followers', 'new_notifications'])
    else:
        profile.save(update_fields=['followers'])

    user_locked.following = user_locked.follows.count()
    user_locked.save(update_fields=['following'])

    if request.is_ajax:
        return {'is_following': followed, 'message': message}
    else:
        messages.success(request, message)
示例#9
0
def user_links(request):
    request.frontend_context.update({
        'REQUEST_ACTIVATION_URL': reverse('misago:request_activation'),
        'FORGOTTEN_PASSWORD_URL': reverse('misago:forgotten_password'),

        'BANNED_URL': reverse('misago:banned'),

        'USERCP_URL': reverse('misago:options'),
        'USERS_LIST_URL': reverse('misago:users'),

        'AUTH_API': reverse('misago:api:auth'),
        'USERS_API': reverse('misago:api:user-list'),

        'CAPTCHA_API_URL': reverse('misago:api:captcha_question'),
        'USERNAME_CHANGES_API': reverse('misago:api:usernamechange-list'),
    })

    return {
        'USERCP_URL': usercp.get_default_link(),
        'USERS_LIST_URL': users_list.get_default_link(),
        'USER_PROFILE_URL': user_profile.get_default_link(),
    }
示例#10
0
    def get(self, request, *args, **kwargs):
        profile = self.get_profile(request, kwargs.pop('pk'), kwargs.pop('slug'))

        return redirect(user_profile.get_default_link(), slug=profile.slug, pk=profile.pk)
示例#11
0
def landing(request, profile):
    return redirect(user_profile.get_default_link(), slug=profile.slug, pk=profile.pk)
示例#12
0
def lander(request, profile):
    return redirect(user_profile.get_default_link(), slug=profile.slug, pk=profile.pk)
示例#13
0
def moderation_return_path(request, user):
    return_path = clean_return_path(request)
    if not return_path:
        return reverse(user_profile.get_default_link(),
                       kwargs={'user_slug': user.slug, 'user_id': user.pk})
    return return_path
示例#14
0
文件: profile.py 项目: nescode/Misago
def lander(request, profile):
    return redirect(user_profile.get_default_link(),
        user_slug=profile.slug,
        user_id=profile.id)
示例#15
0
 def get_absolute_url(self):
     return reverse(user_profile.get_default_link(),
                    kwargs={
                        'user_slug': self.slug,
                        'user_id': self.id,
                    })
示例#16
0
文件: user.py 项目: ZerGabriel/Misago
 def get_absolute_url(self):
     return reverse(user_profile.get_default_link(), kwargs={
         'user_slug': self.slug,
         'user_id': self.id,
     })