aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/apps/profile
diff options
context:
space:
mode:
Diffstat (limited to '97suifangqa/apps/profile')
-rw-r--r--97suifangqa/apps/profile/models.py13
-rw-r--r--97suifangqa/apps/profile/urls.py13
-rw-r--r--97suifangqa/apps/profile/views.py31
3 files changed, 24 insertions, 33 deletions
diff --git a/97suifangqa/apps/profile/models.py b/97suifangqa/apps/profile/models.py
index 2168f39..b926d31 100644
--- a/97suifangqa/apps/profile/models.py
+++ b/97suifangqa/apps/profile/models.py
@@ -10,6 +10,8 @@ from .storage import OverwriteStorage
from .utils import avatar_by_user
from .image import crop
+from sfaccount import models as am
+
class Profile(models.Model):
@@ -25,11 +27,14 @@ class Profile(models.Model):
(3, u"硕士"),
(4, u"博士"))
- user = models.OneToOneField(User, null=True, blank=True)
- name = models.CharField(u"用户名", max_length=20, null=True, blank=True)
- avatar = models.ImageField(u"头像", upload_to="uploads/avatar/", storage=OverwriteStorage())
+ account = models.OneToOneField(am.Account, verbose_name=u"账户")
+ screen_name = models.CharField(u"显示名称",
+ max_length=15, blank=True)
+ #user = models.OneToOneField(User, null=True, blank=True)
+ #name = models.CharField(u"用户名", max_length=20, null=True, blank=True)
+ #avatar = models.ImageField(u"头像", upload_to="uploads/avatar/", storage=OverwriteStorage())
education = models.IntegerField(u"学历", choices=education_choices)
- email = models.EmailField(u"邮箱", primary_key=True)
+ #email = models.EmailField(u"邮箱", primary_key=True)
gender = models.IntegerField(u"性别", choices=gender_choices, default=0)
user_level= models.IntegerField(u"等级", default=0)
medicines = models.ManyToManyField("medicine.Medicine", related_name="users", verbose_name= u"药物", null=True, blank=True)
diff --git a/97suifangqa/apps/profile/urls.py b/97suifangqa/apps/profile/urls.py
index cbc453d..e6c396d 100644
--- a/97suifangqa/apps/profile/urls.py
+++ b/97suifangqa/apps/profile/urls.py
@@ -1,9 +1,10 @@
+# -*- coding: utf-8 -*-
+
from django.conf.urls import patterns, url
-from .views import *
-urlpatterns = patterns('',
- url(r'^login/?$', login, name = "login"),
- url(r'^logout/?$', logout, name = "logout"),
- url(r'^signup/?$', signup, name = "signup"),
- )
+urlpatterns = patterns('profile.views',
+ url(r'^(?P<username>[a-zA-Z_][a-zA-Z0-9_]*)/$',
+ 'profile_view', name='profile_home'),
+)
+
diff --git a/97suifangqa/apps/profile/views.py b/97suifangqa/apps/profile/views.py
index c41e62b..e7d17e9 100644
--- a/97suifangqa/apps/profile/views.py
+++ b/97suifangqa/apps/profile/views.py
@@ -1,30 +1,15 @@
# -*- coding: utf-8 -*-
from django.http import HttpResponse, HttpResponseRedirect
-from django.conf import settings
+from django.conf import settings
from django.shortcuts import render
-from django.contrib.auth.views import login, logout
-from django.contrib.auth import login as auth_login
-from .forms import UserCreationForm
-
-
-def signup(request):
- u'''
- 用户注册
- '''
- if request.user.is_authenticated():
- return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)
-
- if request.method == 'POST':
- form = UserCreationForm(request.POST)
- if form.is_valid():
- user = form.save()
- return HttpResponseRedirect(request.REQUEST.get('next'))
- else:
- form = UserCreationForm()
-
- return render(request, 'registration/signup.html',
- locals())
+# profile home {{{
+def profile_view(request, username):
+ """
+ show profile of given user
+ """
+ return HttpResponse('Hi, %s' % username)
+# }}}