Ejemplo n.º 1
0
def register(request):
    """Render and process a form for members to register with the site."""
    log_page_view(request, 'Register')
    if request.user.is_authenticated():
        return HttpResponseRedirect(reverse('home'))
    if request.method == 'POST':
        form = UserForm(request.POST)
        if form.is_valid():
            create_user_and_profile(form.cleaned_data)
            log.info('Created new user and profile (badge = %d)', form.cleaned_data.get('badge'))
            return HttpResponseRedirect(reverse('register_success'))
    else:
        form = UserForm()
    return render(request, 'brothers/register.html', {'form': form}, context_instance=RequestContext(request))
Ejemplo n.º 2
0
def add(request):
    """Render and process a form for administrators to create new user accounts."""
    log_page_view(request, 'Add User')
    if request.method == 'POST':
        form = UserForm(request.POST)
        if form.is_valid():
            create_user_and_profile(form.cleaned_data)
            log.info('Admin %s (#%d) created new user %s (badge = %d)', request.user.get_full_name(),
                    request.user.get_profile().badge, form.cleaned_data['username'], form.cleaned_data['badge'])
            return HttpResponseRedirect(reverse('manage_users'))
    else:
        form = UserForm()
    return render(request, 'brothers/add.html',
                  {'form': form, 'secret_key': settings.BROTHER_KEY, 'admin_password': settings.ADMIN_KEY},
                  context_instance=RequestContext(request))
Ejemplo n.º 3
0
def register(request):
    """Render and process a form for members to register with the site."""
    log_page_view(request, 'Register')
    if request.user.is_authenticated():
        return HttpResponseRedirect(reverse('home'))
    if request.method == 'POST':
        form = UserForm(request.POST)
        if form.is_valid():
            create_user_and_profile(form.cleaned_data)
            log.info('Created new user and profile (badge = %d)',
                     form.cleaned_data.get('badge'))
            return HttpResponseRedirect(reverse('register_success'))
    else:
        form = UserForm()
    return render(request,
                  'brothers/register.html', {'form': form},
                  context_instance=RequestContext(request))
Ejemplo n.º 4
0
def add(request):
    """Render and process a form for administrators to create new user accounts."""
    log_page_view(request, 'Add User')
    if request.method == 'POST':
        form = UserForm(request.POST)
        if form.is_valid():
            create_user_and_profile(form.cleaned_data)
            log.info('Admin %s (#%d) created new user %s (badge = %d)',
                     request.user.get_full_name(),
                     request.user.get_profile().badge,
                     form.cleaned_data['username'], form.cleaned_data['badge'])
            return HttpResponseRedirect(reverse('manage_users'))
    else:
        form = UserForm()
    return render(request,
                  'brothers/add.html', {
                      'form': form,
                      'secret_key': settings.BROTHER_KEY,
                      'admin_password': settings.ADMIN_KEY
                  },
                  context_instance=RequestContext(request))