Beispiel #1
0
def update_view(request):
    # Authentication check.
    authentication_result = views.authentication_check(request)
    if authentication_result is not None: return authentication_result
    # Get the template data from the asession
    template_data = views.parse_session(request,
                                        {'form_button': "Update profile"})
    # Proceed with the rest of the view
    profile = request.user.account.profile
    if request.method == 'POST':
        if request.user.account.role != Account.ACCOUNT_PATIENT:
            form = EmployeeProfileForm(request.POST)
        else:
            form = ProfileForm(request.POST)
        if form.is_valid():
            form.assign(profile)
            profile.save()
            logger.log(Action.ACTION_ACCOUNT, "Account updated info",
                       request.user.account)
            template_data['alert_success'] = "Your profile has been updated!"
    else:
        if request.user.account.role != Account.ACCOUNT_PATIENT:
            form = EmployeeProfileForm(profile.get_populated_fields())
        else:
            form = ProfileForm(profile.get_populated_fields())
    template_data['form'] = form
    return render(request, 'healthnet/profile/update.html', template_data)
Beispiel #2
0
 def test_inurance_missing(self):
     self.form_data['insurance'] = ''
     form = ProfileForm(data=self.form_data)
     self.assertFalse(form.is_valid())
Beispiel #3
0
 def test_inurance_missing(self):
     self.form_data['insurance'] = ''
     form = ProfileForm(data=self.form_data)
     self.assertFalse(form.is_valid())
Beispiel #4
0
 def test_valid_profile_form(self):
     form = ProfileForm(data=self.form_data)
     self.assertTrue(form.is_valid())
Beispiel #5
0
 def test_valid_profile_form(self):
     form = ProfileForm(data=self.form_data)
     self.assertTrue(form.is_valid())