diff options
Diffstat (limited to 'account')
-rw-r--r-- | account/extra.py | 3 | ||||
-rw-r--r-- | account/models.py | 2 | ||||
-rw-r--r-- | account/views.py | 5 |
3 files changed, 6 insertions, 4 deletions
diff --git a/account/extra.py b/account/extra.py index 8f034c9..e478c6d 100644 --- a/account/extra.py +++ b/account/extra.py @@ -4,8 +4,9 @@ Extra models for app account """ -from django.db import models from django import forms +from django.db import models +from django.db.models.fields.files import FieldFile from django.core.files.storage import FileSystemStorage from django.conf import settings from django.template.defaultfilters import filesizeformat diff --git a/account/models.py b/account/models.py index 9c3f44e..1816c62 100644 --- a/account/models.py +++ b/account/models.py @@ -8,7 +8,6 @@ from django.db import models from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import login -from django.db.models.fields.files import FieldFile from django.utils.translation import ugettext_lazy as _ from django.db.models.signals import pre_delete @@ -73,6 +72,7 @@ class UserProfile(models.Model): # transcript: needed if undergraudate (junior and below) transcript = ContentTypeRestrictedFileField(upload_to=lambda instance, filename: u'account/{0}/{1}'.format(instance.user.username, filename), verbose_name=_("Transcript"), blank=True, null=True, + help_text=_("Undergraduate (junior and below) required to upload transcript."), storage=OverwriteStorage(), content_types=settings.ALLOWED_CONTENT_TYPES, max_upload_size=settings.ALLOWED_MAX_UPLOAD_SIZE) diff --git a/account/views.py b/account/views.py index d998c6e..14be14c 100644 --- a/account/views.py +++ b/account/views.py @@ -10,6 +10,7 @@ from django.views.generic.edit import FormView, UpdateView from django.views.generic.list import ListView from django.core.urlresolvers import reverse_lazy from django.http import HttpResponseRedirect +from django.shortcuts import get_object_or_404 from account.models import UserProfile from account.forms import ResendEmailForm, UpdateProfileForm, UserFileFormSet @@ -40,7 +41,7 @@ class ProfileView(TemplateView): def get_context_data(self, **kwargs): context = super(ProfileView, self).get_context_data(**kwargs) user = self.request.user - profile = user.userprofile_set.get(user=user) + profile = get_object_or_404(UserProfile, user=user) userfiles = user.userfile_set.all() context['user'] = user context['profile'] = profile @@ -134,7 +135,7 @@ class ListApprovedView(ListView): """ context = super(ListApprovedView, self).get_context_data(**kwargs) user = self.request.user - profile = user.userprofile_set.get(user=user) + profile = get_object_or_404(UserProfile, user=user) context['user'] = user context['profile'] = profile return context |