Esempio n. 1
0
def actor_init_form(request):
    try:
        actor = request.user.actor
        return redirect('backstage')
    except Actor.DoesNotExist:
        actor = Actor(user=request.user, status=Configuration.objects.current().default_status)

    if request.POST:
        form_public = ActorPublicForm(request.POST, instance=actor)
        form_data = ActorDataForm(request.POST, instance=actor)
        form_group = UserGroupForm(request.POST)
        if form_public.is_valid() and form_data.is_valid() and form_group.is_valid():
            form_public.save()
            form_data.save()
            request.user.groups.add(form_group.cleaned_data['group'])
            messages.success(request, _(
                u'Vielen Dank! Damit hast du nun dein Profil angelegt. Bitte melde dich nun noch mal an.'))
            return redirect('logout')
    else:
        form_public = ActorPublicForm(instance=actor)
        form_data = ActorDataForm(instance=actor)
        form_group = UserGroupForm()

    forms = ((_(u'Öffentliches Profil'), form_public),
             (_('Stammdaten'), form_data),
             (_(u'Gruppenzugehörigkeit'), form_group))

    return render(request, 'backstage/actor-init-form.html',
                  get_context_backstage(request, 'actor-init-form', {'forms': forms}))
Esempio n. 2
0
def actor_data_form(request):
    actor = request.user.actor

    success_messages = []

    if request.POST:
        form = ActorDataForm(request.POST, instance=actor)
        if form.is_valid():
            form.save()
            success_messages.append(_(u'Deine Stammdaten wurden aktualisiert.'))

        form_picture = PictureMembershipForm(request.POST, request.FILES, instance=actor.picture_membership)
        if form_picture.is_valid():
            form_picture.title = actor.__unicode__()
            actor.picture_membership = form_picture.save()
            actor.save()
            success_messages.append(_(u'Dein internes Profilbild wurde aktualisiert.'))

    else:
        form = ActorDataForm(instance=actor)
        form_picture = PictureMembershipForm(instance=actor.picture_membership)

    if success_messages:
        messages.success(request, ' '.join(success_messages))

    c = {
        'form': form,
        'form_picture': form_picture
    }

    return render(request, 'backstage/actor-data-form.html', get_context_backstage(request,
                                                                                   'actor-data-form',
                                                                                   c))