Ejemplo n.º 1
0
    def test_settings_form(self):
        """
            Tests whether the settings form can be submitted without errors
        """
        user = baker.make(UserProfile,
                          email="*****@*****.**")
        delegate = baker.make(UserProfile,
                              email="*****@*****.**")

        self.assertFalse(
            user.delegates.filter(
                email="*****@*****.**").exists())

        form_data = get_form_data_from_instance(DelegatesForm, user)
        form_data["delegates"] = [delegate.pk]  # add delegate

        form = DelegatesForm(form_data, instance=user)
        self.assertTrue(form.is_valid())
        form.save()

        user = UserProfile.objects.get(
            email="*****@*****.**")
        self.assertTrue(
            user.delegates.filter(
                email="*****@*****.**").exists())
Ejemplo n.º 2
0
def settings_edit(request):
    user = request.user
    form = DelegatesForm(request.POST or None, request.FILES or None, instance=user)

    if form.is_valid():
        form.save()

        messages.success(request, _("Successfully updated your settings."))
        return redirect('contributor:index')
    else:
        return render(request, "contributor_settings.html", dict(form=form, user=user))
Ejemplo n.º 3
0
def settings_edit(request):
    user = request.user
    form = DelegatesForm(request.POST or None, request.FILES or None, instance=user)

    if form.is_valid():
        form.save()

        messages.success(request, _("Successfully updated your settings."))
        return redirect('contributor:index')
    else:
        return render(request, "contributor_settings.html", dict(form=form))
Ejemplo n.º 4
0
def settings_edit(request):
    user = request.user
    form = DelegatesForm(request.POST or None, request.FILES or None, instance=user)

    if form.is_valid():
        form.save()

        messages.success(request, _("Successfully updated your settings."))
        return redirect('contributor:settings_edit')
    else:
        return render(request, "contributor_settings.html", dict(
            form=form,
            delegate_of=user.represented_users.all(),
            cc_users=user.cc_users.all(),
            ccing_users=user.ccing_users.all(),
        ))
Ejemplo n.º 5
0
def settings_edit(request):
    user = request.user
    form = DelegatesForm(request.POST or None, request.FILES or None, instance=user)

    if form.is_valid():
        form.save()

        messages.success(request, _("Successfully updated your settings."))
        return redirect('contributor:settings_edit')
    else:
        return render(request, "contributor_settings.html", dict(
            form=form,
            delegate_of=user.represented_users.all(),
            cc_users=user.cc_users.all(),
            ccing_users=user.ccing_users.all(),
        ))
Ejemplo n.º 6
0
Archivo: tests.py Proyecto: karyon/EvaP
    def test_settings_form(self):
        """
            Tests whether the settings form can be submitted without errors
        """
        user = mommy.make(UserProfile, username="******")
        delegate = mommy.make(UserProfile, username="******")

        self.assertFalse(user.delegates.filter(username="******").exists())

        form_data = get_form_data_from_instance(DelegatesForm, user)
        form_data["delegates"] = [delegate.pk] # add delegate

        form = DelegatesForm(form_data, instance=user)
        self.assertTrue(form.is_valid())
        form.save()

        user = UserProfile.objects.get(username="******")
        self.assertTrue(user.delegates.filter(username="******").exists())