Exemplo n.º 1
0
def active(request):
    if request.is_ajax() and request.user.is_admin():
        userid = request.POST.get('userid')
        try:
            user = User.objects.get(id=userid)
            from usr import active
            active(user)
        except:
            return JsonResponse({'ret':'active failed', 'valid': False}) 
        return JsonResponse({'ret':'active ok', 'valid': True}) 
Exemplo n.º 2
0
def validate(request, key):
    from usr.models import UserCreate
    try:
        from usr import login, active
        user = UserCreate.objects.get(reg_key=key).user
        active(user)
        messages.info(request, 'Welcome %s, your account is actived.' % user.name)
        login(request, user)
    except (KeyError, UserCreate.DoesNotExist):
        messages.add_message(request, messages.INFO, 'The register key is wrong.')
    return HttpResponseRedirect("/")