Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
roomlist
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
roomlist
Commits
380bf360
Commit
380bf360
authored
May 09, 2015
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set up page to list majors
parent
0ad576c5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
5 deletions
+19
-5
roomlist/accounts/models.py
roomlist/accounts/models.py
+3
-0
roomlist/accounts/urls.py
roomlist/accounts/urls.py
+4
-1
roomlist/accounts/views.py
roomlist/accounts/views.py
+10
-2
roomlist/templates/layouts/navbar.html
roomlist/templates/layouts/navbar.html
+2
-2
No files found.
roomlist/accounts/models.py
View file @
380bf360
...
...
@@ -16,6 +16,9 @@ class Major(TimeStampedModel):
name
=
models
.
CharField
(
max_length
=
50
)
# I believe the longest is "Government and International Politics"
def
first_letter
(
self
):
return
self
.
name
and
self
.
name
[
0
]
or
''
def
__str__
(
self
):
return
self
.
name
...
...
roomlist/accounts/urls.py
View file @
380bf360
...
...
@@ -2,13 +2,16 @@
from
django.conf.urls
import
patterns
,
include
,
url
# imports from your apps
from
.views
import
DetailStudent
,
UpdateStudent
,
DetailStudentSettings
,
\
DetailCurrentStudent
,
DetailCurrentStudentSettings
,
UpdateStudentMajor
DetailCurrentStudent
,
DetailCurrentStudentSettings
,
UpdateStudentMajor
,
\
ListMajors
urlpatterns
=
patterns
(
''
,
url
(
r
''
,
include
(
'allauth.urls'
)),
url
(
r
'^majors/$'
,
ListMajors
.
as_view
(),
name
=
'list_majors'
),
url
(
r
'^student/(?P<slug>[\w-]+)/$'
,
DetailStudent
.
as_view
(),
name
=
'detail_student'
),
...
...
roomlist/accounts/views.py
View file @
380bf360
# core django imports
from
django.shortcuts
import
get_object_or_404
from
django.http
import
HttpResponseForbidden
from
django.views.generic
import
DetailView
,
UpdateView
from
django.views.generic
import
ListView
,
DetailView
,
UpdateView
# third party imports
from
braces.views
import
LoginRequiredMixin
# imports from your apps
from
.models
import
Student
from
.models
import
Student
,
Major
# update a student (students are *created* on first login via CAS)
...
...
@@ -117,3 +117,11 @@ class DetailCurrentStudentSettings(LoginRequiredMixin, DetailView):
def
get_object
(
self
):
return
get_object_or_404
(
Student
,
pk
=
self
.
request
.
session
[
'_auth_user_id'
])
class
ListMajors
(
LoginRequiredMixin
,
ListView
):
model
=
Major
queryset
=
Major
.
objects
.
all
().
order_by
(
'name'
)
context_object_name
=
'majors'
template_name
=
'list_majors.html'
login_url
=
'majors'
roomlist/templates/layouts/navbar.html
View file @
380bf360
...
...
@@ -12,8 +12,8 @@
<div
id=
"navbar"
class=
"navbar-collapse collapse"
>
<ul
class=
"nav navbar-nav"
>
{% if user.is_authenticated %}
<li><a
href=
"
/housing"
>
Buildings
</a
>
</li>
<li><a
href=
"
{% url 'list_buildings' %}"
>
Buildings
</a></li
>
<
li><a
href=
"{% url 'list_majors' %}"
>
Majors
</a><
/li>
{% else %}
<li><a
href=
"{% url 'about' %}"
>
About
</a>
</li>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment