コード例 #1
0
ファイル: views.py プロジェクト: shacker/itaco
def apply(request):
    '''
    To avoid creating Users, Families and Students before a family is accepted, and to
    closely mimic the PDF application form, we store everything flat here. Later, if people
    are accepted, we copy fields from an app record into the appropriate models.
    '''

    # Submit a new application
    if request.POST:
        form = ApplicationForm(request.POST, files=request.FILES)

        if form.is_valid():
            # Don't commit the save until we've added in the fields we need to set
            app = form.save(commit=False)
            app.appdate = datetime.now()

            # If user is logged in, they are already a Crestmont family and this
            # app should be associated with that family
            if request.user.is_authenticated():
                app.family = request.user.profile.family

            app.save()

            # Upon successful submit, redirect to the app fee view for this applicant.
            return HttpResponseRedirect(reverse('app_fee', args=[app.id]))
        else:
            # print form.errors
            pass
    else:
        form = ApplicationForm()

    return render_to_response('apply/apply.html', locals(),
        context_instance=RequestContext(request),
    )
コード例 #2
0
def application_save(request, app_id):
    application = get_object_or_404(Application,
                                    id=app_id,
                                    profile=request.user.get_profile())

    # application no longer valid?
    if not application.session.active:
        request.user.message_set.create(
            message=
            'The application session has ended; you cannot edit your application any more.'
        )
        return HttpResponseRedirect(reverse('applications'))

    if request.method == 'POST' and request.is_ajax():
        form = ApplicationForm(request.POST, instance=application)

        if form.is_valid():
            app = form.save()
            return HttpResponse("success")

        return render_to_response('apply/application/form.html', {
            'application': application,
            'form': form
        },
                                  context_instance=RequestContext(request))

    return HttpResponseForbidden()
コード例 #3
0
def apply(request):
    if request.method == 'POST':
        form = ApplicationForm(request.POST)
        if form.is_valid():
            p = form.save(commit=False)
            p.date = datetime.now()
            form.save()
    else:
        form = ApplicationForm()
    args = {
        'form': form
    }
    return render(request, 'apply/apply.html', args)
コード例 #4
0
ファイル: applications.py プロジェクト: alexnjoyce/myewb2
def application_save(request, app_id):
    application = get_object_or_404(Application, id=app_id, profile=request.user.get_profile())
    
    # application no longer valid?
    if not application.session.active:
        request.user.message_set.create(message='The application session has ended; you cannot edit your application any more.')
        return HttpResponseRedirect(reverse('applications'))

    if request.method == 'POST' and request.is_ajax():
        form = ApplicationForm(request.POST, instance=application)
        
        if form.is_valid():
            app = form.save()
            return HttpResponse("success")
            
        return render_to_response('apply/application/form.html',
                                  {'application': application,
                                   'form': form
                                  },
                                  context_instance=RequestContext(request))
    
    return HttpResponseForbidden()
コード例 #5
0
def apply(request):
    """Display the form to add a new Application to the database."""
    if request.method == 'POST':
        form = ApplicationForm(request.POST)
        if form.is_valid():  # All validation rules pass; form is savable.
            form.save()

            return http.HttpResponseRedirect(reverse('thanks'))
    else:
        form = ApplicationForm()

    return jingo.render(request, 'apply/apply.html', {'form': form})
コード例 #6
0
def application_edit(request, app_id):
    application = get_object_or_404(Application,
                                    id=app_id,
                                    profile=request.user.get_profile())

    # application no longer valid?
    if not application.session.active:
        request.user.message_set.create(
            message=
            'The application session has ended; you cannot edit your application any more.'
        )
        return HttpResponseRedirect(
            reverse('applications_detail', kwargs={'app_id': application.id}))

    form = ApplicationForm(instance=application)

    # render response.  (no processing done here; that's all elsewhere in AJAX)
    return render_to_response('apply/application/apply.html', {
        "application": application,
        "form": form,
    },
                              context_instance=RequestContext(request))
コード例 #7
0
 def test_portfolio_website_field_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(
         form.fields["portfolio_website"].label == "Portfolio website")
コード例 #8
0
 def test_update_profile_is_bool(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertIsInstance(form.fields["update_profile"], BooleanField)
コード例 #9
0
 def test_health_conditions_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(
         form.fields["health_conditions"].label == "Health conditions")
コード例 #10
0
 def test_veteran_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(form.fields["veteran"].label == "Veteran")
コード例 #11
0
 def test_ethnicity_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(form.fields["ethnicity"].label == "Ethnicity")
コード例 #12
0
 def test_race_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(form.fields["race"].label == "Race")
コード例 #13
0
 def test_cover_letter_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(form.fields["cover_letter"].label == "Cover letter")
コード例 #14
0
 def test_gender_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(form.fields["gender"].label == "Gender")
コード例 #15
0
 def test_last_name_field_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(form.fields["last_name"].label == "Last name")
コード例 #16
0
 def test_phone_field_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(form.fields["phone"].label == "Phone")
コード例 #17
0
 def test_zip_code_field_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(form.fields["zip_code"].label == "Zip code")
コード例 #18
0
 def test_address_field_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(form.fields["address_line"].label == "Address line")
コード例 #19
0
 def test_email_field_label(self):
     form = ApplicationForm(instance=self.candidate)
     self.assertTrue(form.fields["email"].label == "Email")