aboutsummaryrefslogtreecommitdiffstats
path: root/account
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-04-29 00:49:26 +0800
committerWeitian LI <liweitianux@gmail.com>2014-04-29 00:49:26 +0800
commitb95b09491a12745de669e57a91167dd9ec5b3d0a (patch)
tree212eb442f31312917f05bd0e5b073a8314d5527e /account
parentefe31dcaf500ac93338c1e493672dbedbcecde7a (diff)
downloaddjango-skaschool-b95b09491a12745de669e57a91167dd9ec5b3d0a.tar.bz2
* fixed FieldFile import problem of account/extra.py
* updated models.py and added 'help_text' to transcript field * using 'get_object_or_404' in views.py instead of simply get method
Diffstat (limited to 'account')
-rw-r--r--account/extra.py3
-rw-r--r--account/models.py2
-rw-r--r--account/views.py5
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