Example #1
0
def admin_general_infos(request, association_name):
    """
    Edits association's general informations.

    :param request: request object
    :param association_name: name of the association to edit
    """

    association = get_object_or_404(Association, name=association_name)
    current_year = association.signing_year  # util.get_current_year()

    # The connected user must be a board member (status < 5)
    if not Member.objects.filter(
            user=request.user.id, association=association.id,
            year=current_year, status__lt=5).exists():
        raise PermissionDenied

    message = False  # TODO : use the message middleware for confirmations
    information_form = GeneralInformationForm(
        request.POST or None, request.FILES or None, instance=association)

    if information_form.is_valid():
        information_form.save()
        message = True

    return render_to_response(
        "admin_general_info.html",
        {
            'request': request,
            'association': association,
            'form': information_form,
            'message': message
        },
        context_instance=RequestContext(request))
Example #2
0
    def test_new_form_cotisation(self):
        """
        Unit test for the subscription field in a form.
        """
        form_data = {
            'name': 'Cutie Mark Crusader',
            'description': 'foo',
            'campus': 0,
            'cotisation': -42  # This should fail
            }
        form = GeneralInformationForm(data=form_data)
        self.assertFalse(form.is_valid())

        form_data = {
            'name': 'Cutie Mark Crusader',
            'description': 'foo',
            'campus': 0,
            'subscription': 42  # This should not fail
            }
        form = GeneralInformationForm(data=form_data)
        self.assertTrue(form.is_valid())