Commit 268815a1 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

fixed this error, though want to change the flow eventually

parent 8ac74f4c
......@@ -20,7 +20,7 @@ urlpatterns = patterns('',
template_name='detailStudent.html'),
name='detailCurrentStudent'),
url(r'^(?P<slug>[\w-]+)/welcome/$',
url(r'^student/(?P<slug>[\w-]+)/welcome/$',
UpdateStudent.as_view(
model=Student,
template_name="updateStudent.html"),
......
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseForbidden
from django.views.generic import DetailView, ListView, UpdateView, UpdateView, DeleteView
......@@ -11,11 +12,20 @@ class UpdateStudent(LoginRequiredMixin, UpdateView):
model = Student
fields = ['room', 'privacy',]
login_url = '/'
login_url = 'login'
# copied from below
def get_object(self):
return get_object_or_404(Student, pk=self.request.session['_auth_user_id'])
def get(self, request, *args, **kwargs):
current_url = self.request.get_full_path()
url_uname = current_url.split('/')[3]
print url_uname, self.request.user.username
if not(url_uname == self.request.user.username):
print "I'm sorry, what now?"
return HttpResponseForbidden()
else:
return super(UpdateStudent, self).get(request, *args, **kwargs)
class UpdateStudentMajor(LoginRequiredMixin, UpdateView):
models = Student
......
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