Commit 57a397bc authored by Daniel W Bond's avatar Daniel W Bond
Browse files

students can now change their majors

parent a5c462b2
{% extends 'layouts/base.html' %}
{% block title %} SRCT RoomList | Student Major {% endblock %}
{% block reminder %}
{% endblock %}
{% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12 text-center">
<h1><strong>SRCT</strong>ROOMLIST</a></strong> Student Major</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="row">
<div class="col-md-12 text-center">
<div class="alert alert-danger" role="alert">
<p><i class="fa fa-exclamation-circle fa-fw fa-lg"></i> <strong>Changing your major here serves only to make it easier for others to find you on this site.</strong></p>
<p>Talk with your academic advisor and file all necessary paperwork to officially change your major with the registrar.</p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title text-center"><strong>Set your major on ROOMLIST!</strong></h1>
</div>
<div class="panel-body">
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save" class="btn btn-primary"/>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
from django.conf.urls import patterns, include, url from django.conf.urls import patterns, include, url
from accounts.views import DetailStudent, UpdateStudent, DetailStudentSettings, DetailCurrentStudent, DetailCurrentStudentSettings from accounts.views import DetailStudent, UpdateStudent, DetailStudentSettings, DetailCurrentStudent, DetailCurrentStudentSettings, UpdateStudentMajor
from accounts.models import Student from accounts.models import Student
urlpatterns = patterns('', urlpatterns = patterns('',
...@@ -26,6 +26,12 @@ urlpatterns = patterns('', ...@@ -26,6 +26,12 @@ urlpatterns = patterns('',
template_name="updateStudent.html"), template_name="updateStudent.html"),
name='updateStudent'), name='updateStudent'),
url(r'^(?P<slug>[\w-]+)/major/$',
UpdateStudentMajor.as_view(
model=Student,
template_name="updateStudentMajor.html"),
name='updateStudentMajor'),
url(r'^settings/$', url(r'^settings/$',
DetailCurrentStudentSettings.as_view( DetailCurrentStudentSettings.as_view(
model=Student, model=Student,
......
...@@ -17,6 +17,16 @@ class UpdateStudent(LoginRequiredMixin, UpdateView): ...@@ -17,6 +17,16 @@ class UpdateStudent(LoginRequiredMixin, UpdateView):
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'])
class UpdateStudentMajor(LoginRequiredMixin, UpdateView):
models = Student
fields = ['major',]
login_url = '/'
# copied from below
# def get_object(self):
# return get_object_or_404(Student, pk=self.request.session['_auth_user_id'])
# details about the student # details about the student
class DetailStudent(LoginRequiredMixin, DetailView): class DetailStudent(LoginRequiredMixin, DetailView):
model = Student model = Student
...@@ -70,7 +80,7 @@ class DetailStudentSettings(LoginRequiredMixin, DetailView): ...@@ -70,7 +80,7 @@ class DetailStudentSettings(LoginRequiredMixin, DetailView):
login_url = '/' login_url = '/'
class DetailCurrentStudentSettings(LoginRequiredMixin, DetailView): class DetailCurrentStudentSettings(LoginRequiredMixin, DetailView):
#model = Student model = Student
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