Commit 7beb2bf2 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

removed login from urls for accounts app

parent 42fc6d6c
...@@ -3,42 +3,25 @@ from django.conf.urls import patterns, include, url ...@@ -3,42 +3,25 @@ from django.conf.urls import patterns, include, url
# imports from your apps # imports from your apps
from .views import DetailStudent, UpdateStudent, DetailStudentSettings,\ from .views import DetailStudent, UpdateStudent, DetailStudentSettings,\
DetailCurrentStudent, DetailCurrentStudentSettings, UpdateStudentMajor DetailCurrentStudent, DetailCurrentStudentSettings, UpdateStudentMajor
from .models import Student
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'', include('allauth.urls')), url(r'', include('allauth.urls')),
url(r'^student/(?P<slug>[\w-]+)/$', url(r'^student/(?P<slug>[\w-]+)/$',
DetailStudent.as_view( DetailStudent.as_view(), name='detail_student'),
model=Student,
context_object_name='student',
template_name='detailStudent.html'),
name='detail_student'),
url(r'^student/$', url(r'^student/$',
DetailCurrentStudent.as_view( DetailCurrentStudent.as_view(), name='detailCurrentStudent'),
model=Student,
context_object_name='student',
template_name='detailStudent.html'),
name='detailCurrentStudent'),
url(r'^student/(?P<slug>[\w-]+)/welcome/$', url(r'^student/(?P<slug>[\w-]+)/welcome/$',
UpdateStudent.as_view( UpdateStudent.as_view(), name='updateStudent'),
model=Student,
template_name="updateStudent.html"),
name='updateStudent'),
url(r'^(?P<slug>[\w-]+)/major/$', url(r'^(?P<slug>[\w-]+)/major/$',
UpdateStudentMajor.as_view( UpdateStudentMajor.as_view(), name='updateStudentMajor'),
model=Student,
template_name="updateStudentMajor.html"),
name='updateStudentMajor'),
url(r'^settings/$', url(r'^settings/$',
DetailCurrentStudentSettings.as_view( DetailCurrentStudentSettings.as_view(), name='currentStudentSettings'),
model=Student,
context_object_name='student',
template_name="studentSettings.html"),
name='currentStudentSettings'),
) )
...@@ -12,6 +12,8 @@ from .models import Student ...@@ -12,6 +12,8 @@ from .models import Student
class UpdateStudent(LoginRequiredMixin, UpdateView): class UpdateStudent(LoginRequiredMixin, UpdateView):
model = Student model = Student
fields = ['room', 'privacy',] fields = ['room', 'privacy',]
context_object_name = 'student'
template_name = 'updateStudent.html'
login_url = 'login' login_url = 'login'
...@@ -31,8 +33,9 @@ class UpdateStudent(LoginRequiredMixin, UpdateView): ...@@ -31,8 +33,9 @@ class UpdateStudent(LoginRequiredMixin, UpdateView):
class UpdateStudentMajor(LoginRequiredMixin, UpdateView): class UpdateStudentMajor(LoginRequiredMixin, UpdateView):
models = Student models = Student
fields = ['major',] fields = ['major',]
template_name = 'updateStudentMajor.html'
login_url = '/' login_url = 'login'
# copied from below # copied from below
# def get_object(self): # def get_object(self):
...@@ -41,6 +44,10 @@ class UpdateStudentMajor(LoginRequiredMixin, UpdateView): ...@@ -41,6 +44,10 @@ class UpdateStudentMajor(LoginRequiredMixin, UpdateView):
# details about the student # details about the student
class DetailStudent(LoginRequiredMixin, DetailView): class DetailStudent(LoginRequiredMixin, DetailView):
model = Student model = Student
context_object_name = 'student'
template_name = 'detailStudent.html'
login_url = 'login'
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(DetailStudent, self).get_context_data(**kwargs) context = super(DetailStudent, self).get_context_data(**kwargs)
...@@ -77,10 +84,12 @@ class DetailStudent(LoginRequiredMixin, DetailView): ...@@ -77,10 +84,12 @@ class DetailStudent(LoginRequiredMixin, DetailView):
context['shares'] = shares() context['shares'] = shares()
return context return context
login_url = '/'
class DetailCurrentStudent(LoginRequiredMixin, DetailView): class DetailCurrentStudent(LoginRequiredMixin, DetailView):
#model = Student model = Student
context_object_name = 'student'
template_name = 'detailStudent.html'
login_url = 'login'
def get_object(self): def get_object(self):
return get_object_or_404(Student, pk=self.request.session['_auth_user_id']) return get_object_or_404(Student, pk=self.request.session['_auth_user_id'])
...@@ -88,10 +97,17 @@ class DetailCurrentStudent(LoginRequiredMixin, DetailView): ...@@ -88,10 +97,17 @@ class DetailCurrentStudent(LoginRequiredMixin, DetailView):
# changeable student settings # changeable student settings
class DetailStudentSettings(LoginRequiredMixin, DetailView): class DetailStudentSettings(LoginRequiredMixin, DetailView):
model = Student model = Student
login_url = '/' context_object_name = 'student'
template_name = 'studentSettings.html'
login_url = 'login'
class DetailCurrentStudentSettings(LoginRequiredMixin, DetailView): class DetailCurrentStudentSettings(LoginRequiredMixin, DetailView):
model = Student model = Student
context_object_name = 'student'
template_name = 'studentSettings.html'
login_url = 'login'
def get_object(self): def get_object(self):
return get_object_or_404(Student, pk=self.request.session['_auth_user_id']) return get_object_or_404(Student, pk=self.request.session['_auth_user_id'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment