예제 #1
0
    def form_valid(self, form):
        ''' When valid.
        '''
        if self.command == "commit":
            EnrollAction(self.request).enroll_by_web(
                form.cleaned_data['username'],
                form.cleaned_data['password'],
                form.cleaned_data['email'],
                form.cleaned_data['group'],
            )

        #:return redirect(self.get_success_url())
        return self.render_to_response(self.get_context_data(form=form))
예제 #2
0
def enroll(request, command, secret):
    result = "default"
    templates = "accounts/enroll/%s/%s.html"
    user = None
    error = None

    if command == "activate":
        enroll = EnrollAction(request).activate(secret)
        if enroll == None:
            result = "error"
            error = "invalid url to activate"
        user = enroll.mailbox.user
    else:
        result, error = "error", "command unknown"

    return render_to_response(
        templates % (command, result),
        {
            "user": user,
            "error": error
        },
        context_instance=template.RequestContext(request),
    )