Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS699_COURSEBOOK
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
AMAN MORESHWAR JANGDE
CS699_COURSEBOOK
Commits
f54704fc
Commit
f54704fc
authored
Nov 26, 2019
by
AMAN MORESHWAR JANGDE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prof module impl
parent
c9c97d64
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
444 additions
and
18 deletions
+444
-18
.gitignore
.gitignore
+1
-1
coursebook/urls.py
coursebook/urls.py
+12
-0
discussion/migrations/0002_subject_student_is_accepted.py
discussion/migrations/0002_subject_student_is_accepted.py
+18
-0
discussion/models.py
discussion/models.py
+1
-0
discussion/templates/available_subjects.html
discussion/templates/available_subjects.html
+7
-1
discussion/templates/base.html
discussion/templates/base.html
+3
-2
discussion/templates/default.html
discussion/templates/default.html
+2
-1
discussion/templates/discussion_topics.html
discussion/templates/discussion_topics.html
+8
-5
discussion/templates/pending_subjects.html
discussion/templates/pending_subjects.html
+45
-0
discussion/templates/prof_discussion_topics.html
discussion/templates/prof_discussion_topics.html
+92
-0
discussion/templates/prof_home.html
discussion/templates/prof_home.html
+17
-0
discussion/templates/prof_subjects.html
discussion/templates/prof_subjects.html
+39
-0
discussion/templates/students_list.html
discussion/templates/students_list.html
+56
-0
discussion/templates/subjects.html
discussion/templates/subjects.html
+18
-6
discussion/views.py
discussion/views.py
+125
-2
djangodb
djangodb
+0
-0
No files found.
.gitignore
View file @
f54704fc
*.sqlite3
\ No newline at end of file
djangodb
\ No newline at end of file
coursebook/urls.py
View file @
f54704fc
...
...
@@ -29,11 +29,23 @@ urlpatterns = [
path
(
''
,
views
.
default
),
path
(
'subjects/'
,
views
.
show_subjects
),
path
(
'available_subjects/'
,
views
.
show_all_subjects
),
path
(
'pending_subjects/'
,
views
.
show_pending_subjects
),
path
(
'reject_subject/<str:sub_code>'
,
views
.
reject_subject
),
path
(
'request_subject/<str:sub_code>'
,
views
.
request_subject
),
path
(
'withdraw_subject/<str:sub_code>'
,
views
.
withdraw_subject
),
path
(
'topics/<str:id>'
,
views
.
show_topics
),
path
(
'threads/<int:id>'
,
views
.
show_threads
),
path
(
'login'
,
views
.
login
),
path
(
'signup'
,
views
.
signup
),
path
(
'logout'
,
views
.
logout
),
path
(
'prof/'
,
views
.
prof_home
),
path
(
'prof/subjects/'
,
views
.
prof_subjects
),
path
(
'prof/student_list/<str:sub_code>'
,
views
.
student_list
),
path
(
'prof/student/accept/<str:sub_code>/<int:pid>'
,
views
.
accept_student
),
path
(
'prof/student/reject/<str:sub_code>/<int:pid>'
,
views
.
reject_student
),
# path('add_thread/<int:id>', views.add_message),
]
discussion/migrations/0002_subject_student_is_accepted.py
0 → 100644
View file @
f54704fc
# Generated by Django 2.0.3 on 2019-11-25 19:50
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'discussion'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'subject_student'
,
name
=
'is_accepted'
,
field
=
models
.
BooleanField
(
default
=
False
),
),
]
discussion/models.py
View file @
f54704fc
...
...
@@ -28,6 +28,7 @@ class Subject(models.Model):
class
Subject_Student
(
models
.
Model
):
subject
=
models
.
ForeignKey
(
Subject
,
on_delete
=
models
.
CASCADE
)
student
=
models
.
ForeignKey
(
Person
,
on_delete
=
models
.
CASCADE
)
is_accepted
=
models
.
BooleanField
(
default
=
False
)
class
Meta
:
db_table
=
"subject_student"
...
...
discussion/templates/available_subjects.html
View file @
f54704fc
...
...
@@ -4,6 +4,7 @@
{% block nav-subjects %}
<li
><a
href=
"/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-available-subjects %}
<li
class=
"active"
><a
href=
"/available_subjects"
>
Available Subjects
</a></li>
{% endblock %}
{% block nav-pending-subjects %}
<li><a
href=
"/pending_subjects"
>
Pending Requests
</a></li>
{% endblock %}
{% block body%}
<div
class=
"container"
style=
"margin-top:50px;"
>
<div
style=
"width: 70%; margin-left: 20px;"
>
...
...
@@ -24,7 +25,12 @@
<td
style=
"text-align: center;"
>
{{ subject.sub_code }}
</td>
<td
style=
"text-align: center;"
>
{{ subject.sub_name }}
</td>
<td
style=
"text-align: center;"
>
{{ subject.prof.fname }} {{ subject.prof.lname }}
</td>
<td
style=
"text-align: center;"
><button
class=
"btn btn-primary"
>
Request
</button></td>
<td
style=
"text-align: center;"
>
<a
href=
"/request_subject/{{subject.sub_code}}"
>
<button
class=
"btn btn-primary"
>
Request
</button>
</a>
</td>
</tr>
{% endfor %}
</tbody>
...
...
discussion/templates/base.html
View file @
f54704fc
...
...
@@ -34,7 +34,7 @@
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
</button>
<a
class=
"navbar-brand"
href=
"/"
>
Coursebook
</a>
{% block nav-brand %}
<a
class=
"navbar-brand"
href=
"/"
>
Coursebook
</a>
{% endblock %}
</div>
<div
class=
"collapse navbar-collapse"
id=
"mynavbar"
>
...
...
@@ -43,6 +43,7 @@
{% if context is not None %}
{% block nav-subjects %}
<li><a
href=
"/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-available-subjects %}
<li><a
href=
"/available_subjects"
>
Available Subjects
</a></li>
{% endblock %}
{% block nav-pending-subjects %}{% endblock %}
{% endif %}
</ul>
...
...
@@ -52,7 +53,7 @@
{% block nav-signup %}
<li><a
href=
"/signup"
><span
class=
"glyphicon glyphicon-user"
></span>
Sign Up
</a></li>
{%endblock%}
{%block nav-login%}
<li><a
href=
"/login"
><span
class=
"glyphicon glyphicon-log-in"
></span>
Login
</a></li>
{%endblock%}
{% else %}
<li><a
href=
"/"
><span
class=
"glyphicon glyphicon-user"
></span>
{{context}}
</a></li>
{% block nav-profile %}
<li><a
href=
"/"
><span
class=
"glyphicon glyphicon-user"
></span>
{{context}}
</a></li>
{%endblock%}
<li><a
href=
"/logout"
><span
class=
"glyphicon glyphicon-log-in"
></span>
Logout
</a></li>
{% endif %}
</ul>
...
...
discussion/templates/default.html
View file @
f54704fc
...
...
@@ -4,8 +4,9 @@
{% block nav-subjects %}
<li
><a
href=
"/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-available-subjects %}
<li><a
href=
"/available_subjects"
>
Available Subjects
</a></li>
{% endblock %}
{% block nav-pending-subjects %}
<li><a
href=
"/pending_subjects"
>
Pending Requests
</a></li>
{% endblock %}
{% block body%}
<div
class=
"container"
style=
"margin-top:
7
0px;"
>
<div
class=
"container"
style=
"margin-top:
25
0px;"
>
{% load static %}
<img
src=
"{%static 'img/logo.png'%}"
width=
"80%"
height=
"50%"
style=
"margin: auto; padding-left: 18%"
/>
<br><br>
...
...
discussion/templates/discussion_topics.html
View file @
f54704fc
...
...
@@ -4,8 +4,9 @@
{% block style-discussion-topics %}
<link
rel=
"stylesheet"
href=
"{% static 'css/discussion_topics.css' %}"
>
{% endblock %}
{% block nav-home %}
<li><a
href=
"/"
>
Home
</a></li>
{% endblock %}
{% block nav-subjects %}
<li><a
href=
"/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-search-subjects %}
<li><a
href=
"/subjects"
>
Search Subjects
</a></li>
{% endblock %}
{% block nav-subjects %}
<li
class=
"active"
><a
href=
"/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-pending-subjects %}
<li
><a
href=
"/pending_subjects"
>
Pending Requests
</a></li>
{% endblock %}
{% block body%}
<div
class=
"container message-wrap "
style=
"margin-top:50px"
>
<p>
...
...
@@ -73,9 +74,11 @@
<div>
{{form.title}}
</div>
{% if is_prof == False %}
<div>
<span>
Include Prof {{form.is_prof_included}}
</span>
</div>
{% endif %}
</div>
<div>
<button
type=
"submit"
class=
" col-sm-4 btn send-message-btn"
role=
"button"
><i
class=
"fa fa-plus"
></i>
Add Topic
</a>
...
...
discussion/templates/pending_subjects.html
0 → 100644
View file @
f54704fc
{% extends "base.html" %}
{% block nav-home %}
<li><a
href=
"/"
>
Home
</a></li>
{% endblock %}
{% block nav-subjects %}
<li
><a
href=
"/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-available-subjects %}
<li
><a
href=
"/available_subjects"
>
Available Subjects
</a></li>
{% endblock %}
{% block nav-pending-subjects %}
<li
class=
"active"
><a
href=
"/pending_subjects"
>
Pending Requests
</a></li>
{% endblock %}
{% block body%}
<div
class=
"container"
style=
"margin-top:50px;"
>
<div
style=
"width: 70%; margin-left: 20px;"
>
<h2>
Pending Course Requests
</h2>
<table
style=
"width:100%;border: solid grey 1px;box-shadow: 2px 2px;"
class=
"table table-hover"
>
<thead>
<tr>
<th
style=
"text-align: center;"
>
Course ID
</th>
<th
style=
"text-align: center;"
>
Course Name
</th>
<th
style=
"text-align: center;"
>
Professor
</th>
<th
style=
"text-align: center;"
>
Action
</th>
</tr>
</thead>
<tbody>
{% for sub_stud in sub_studs %}
{% if sub_stud.is_accepted == False %}
<tr>
<td
style=
"text-align: center;"
>
{{ sub_stud.subject.sub_code }}
</td>
<td
style=
"text-align: center;"
>
{{ sub_stud.subject.sub_name }}
</td>
<td
style=
"text-align: center;"
>
{{ sub_stud.subject.prof.fname }} {{ sub_stud.subject.prof.lname }}
</td>
<td
style=
"text-align: center;"
>
<a
href=
"/reject_subject/{{sub_stud.subject.sub_code}}"
>
<button
class=
"btn btn-danger"
>
Cancel
</button>
</a>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
discussion/templates/prof_discussion_topics.html
0 → 100644
View file @
f54704fc
{% extends "base.html" %}
{% load static %}
{% block style-discussion-topics %}
<link
rel=
"stylesheet"
href=
"{% static 'css/discussion_topics.css' %}"
>
{% endblock %}
{% block nav-brand %}
<a
class=
"navbar-brand"
href=
"/prof"
>
Coursebook
</a>
{% endblock %}
{% block nav-home %}
<li
><a
href=
"/prof"
>
Home
</a></li>
{% endblock %}
{% block nav-subjects %}
<li
class=
"active"
><a
href=
"/prof/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-available-subjects %}{% endblock %}
{% block nav-profile %}
<li><a
href=
"/prof"
><span
class=
"glyphicon glyphicon-user"
></span>
{{context}}
</a></li>
{%endblock%}
{% block body%}
<div
class=
"container message-wrap "
style=
"margin-top:50px"
>
<p>
<h3>
Topics in {{sub_code}}
</h3>
</p>
<div
class=
"list-view"
>
<div
class=
"list-group"
>
{% for topic in topics %}
<a
href=
"/threads/{{topic.id}}"
class=
"list-group-item"
>
<!-- <div class="time">
<div ><i class="fa fa-calendar"></i> Saturday</div>
<div >12/12/19</div>
<div ><i class="fa fa-clock-o"></i> 12.10pm</div>
</div> -->
<div
class=
"topic-body"
>
<h4
class=
"list-group-item-heading"
>
{{topic.title}}
</h4>
<!-- <p class="list-group-item-text">List Group Item Text List Group Item Text List Group Item Text List Group Item Text</p> -->
</div>
</a>
{% endfor %}
<!-- <a href="#" class="list-group-item">
<div class="time">
<div ><i class="fa fa-calendar"></i> Saturday</div>
<div >12/12/19</div>
<div ><i class="fa fa-clock-o"></i> 12.10pm</div>
</div>
<div class="topic-body">
<h4 class="list-group-item-heading">First List Group Item Heading</h4>
<p class="list-group-item-text">List Group Item Text List Group Item Text List Group Item Text List Group Item Text</p>
</div>
</a>
<a href="#" class="list-group-item">
<div class="time">
<div ><i class="fa fa-calendar"></i> Saturday</div>
<div >12/12/19</div>
<div ><i class="fa fa-clock-o"></i> 12.10pm</div>
</div>
<div class="topic-body">
<h4 class="list-group-item-heading">First List Group Item Heading</h4>
<p class="list-group-item-text">List Group Item Text List Group Item Text List Group Item Text List Group Item Text</p>
</div>
</a>
<a href="#" class="list-group-item">
<div class="time">
<div ><i class="fa fa-calendar"></i> Saturday</div>
<div >12/12/19</div>
<div ><i class="fa fa-clock-o"></i> 12.10pm</div>
</div>
<div class="topic-body">
<h4 class="list-group-item-heading">First List Group Item Heading</h4>
<p class="list-group-item-text">List Group Item Text List Group Item Text List Group Item Text List Group Item Text</p>
</div>
</a> -->
<div
class=
"send-wrap "
>
<form
method=
"POST"
class=
"post-form"
action=
"/topics/{{sub_code}}"
>
{% csrf_token %}
<br>
<p
class=
"add-new-topic"
>
Add New Topic
</p>
<div>
{{form.title}}
</div>
{% if is_prof == False %}
<div>
<span>
Include Prof {{form.is_prof_included}}
</span>
</div>
{% endif %}
</div>
<div>
<button
type=
"submit"
class=
" col-sm-4 btn send-message-btn"
role=
"button"
><i
class=
"fa fa-plus"
></i>
Add Topic
</a>
</div>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
discussion/templates/prof_home.html
0 → 100644
View file @
f54704fc
{% extends "base.html" %}
{% block nav-brand %}
<a
class=
"navbar-brand"
href=
"/prof"
>
Coursebook
</a>
{% endblock %}
{% block nav-home %}
<li
class=
"active"
><a
href=
"/prof"
>
Home
</a></li>
{% endblock %}
{% block nav-subjects %}
<li
><a
href=
"/prof/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-available-subjects %}{% endblock %}
{% block nav-profile %}
<li><a
href=
"/prof"
><span
class=
"glyphicon glyphicon-user"
></span>
{{context}}
</a></li>
{%endblock%}
{% block body%}
<div
class=
"container"
style=
"margin-top:250px;"
>
{% load static %}
<img
src=
"{%static 'img/logo.png'%}"
width=
"80%"
height=
"50%"
style=
"margin: auto; padding-left: 18%"
/>
<br><br>
</div>
{% endblock %}
discussion/templates/prof_subjects.html
0 → 100644
View file @
f54704fc
{% extends "base.html" %}
{% block nav-brand %}
<a
class=
"navbar-brand"
href=
"/prof"
>
Coursebook
</a>
{% endblock %}
{% block nav-home %}
<li
><a
href=
"/prof"
>
Home
</a></li>
{% endblock %}
{% block nav-subjects %}
<li
class=
"active"
><a
href=
"/prof/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-available-subjects %}{% endblock %}
{% block nav-profile %}
<li><a
href=
"/prof"
><span
class=
"glyphicon glyphicon-user"
></span>
{{context}}
</a></li>
{%endblock%}
{% block body%}
<div
class=
"container"
style=
"margin-top:50px;"
>
<div
style=
"width: 70%; margin-left: 20px;"
>
<h2>
Courses
</h2>
<table
style=
"width:100%;border: solid grey 1px;box-shadow: 2px 2px;"
class=
"table table-hover"
>
<thead>
<tr>
<th
style=
"text-align: center;"
>
Course ID
</th>
<th
style=
"text-align: center;"
>
Course Name
</th>
<th
style=
"text-align: center;"
>
Links
</th>
</tr>
</thead>
<tbody>
{% for subject in subjects %}
<tr>
<td
style=
"text-align: center;"
><a
href=
"/topics/{{ subject.sub_code }}"
>
{{ subject.sub_code }}
</a></td>
<td
style=
"text-align: center;"
>
{{ subject.sub_name }}
</td>
<td
style=
"text-align: center;"
><a
href=
"/prof/student_list/{{ subject.sub_code }}"
>
View Students
</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
discussion/templates/students_list.html
0 → 100644
View file @
f54704fc
{% extends "base.html" %}
{% block nav-brand %}
<a
class=
"navbar-brand"
href=
"/prof"
>
Coursebook
</a>
{% endblock %}
{% block nav-home %}
<li
><a
href=
"/prof"
>
Home
</a></li>
{% endblock %}
{% block nav-subjects %}
<li
><a
href=
"/prof/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-available-subjects %}{% endblock %}
{% block nav-profile %}
<li><a
href=
"/prof"
><span
class=
"glyphicon glyphicon-user"
></span>
{{context}}
</a></li>
{%endblock%}
{% block body%}
<div
class=
"container"
style=
"margin-top:50px;"
>
<div
style=
"width: 70%; margin-left: 20px;"
>
<h2><span>
{{subject.sub_code}}
</span>
-
<span>
{{subject.sub_name}}
</span></h2>
<table
style=
"width:100%;border: solid grey 1px;box-shadow: 2px 2px;"
class=
"table table-hover"
>
<thead>
<tr>
<th
style=
"text-align: center;"
>
Enrollment Number
</th>
<th
style=
"text-align: center;"
>
First Name
</th>
<th
style=
"text-align: center;"
>
Last Name
</th>
<th
style=
"text-align: center;"
>
Status
</th>
<th
style=
"text-align: center;"
>
Action
</th>
</tr>
</thead>
<tbody>
{% for sub_stud in sub_studs %}
<tr>
<td
style=
"text-align: center;"
>
{{ sub_stud.student.pid }}
</td>
<td
style=
"text-align: center;"
>
{{ sub_stud.student.fname }}
</td>
<td
style=
"text-align: center;"
>
{{ sub_stud.student.lname }}
</td>
{% if sub_stud.is_accepted %}
<td
style=
"text-align: center;"
><button
class=
"btn btn-default"
>
Accepted
</button></td>
{% else %}
<td
style=
"text-align: center;"
><button
class=
"btn btn-default"
>
Pending...
</button></td>
{% endif %}
<td
style=
"text-align: center;"
>
{% if sub_stud.is_accepted %}
<button
class=
"btn btn-basic"
>
Accept
</button>
<a
href=
"/prof/student/reject/{{subject.sub_code}}/{{ sub_stud.student.pid }}"
><button
class=
"btn btn-danger"
>
Remove
</button></a>
{% else %}
<a
href=
"/prof/student/accept/{{subject.sub_code}}/{{ sub_stud.student.pid }}"
><button
class=
"btn btn-success"
>
Accept
</button></a>
<a
href=
"/prof/student/reject/{{subject.sub_code}}/{{ sub_stud.student.pid }}"
><button
class=
"btn btn-danger"
>
Reject
</button></a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
discussion/templates/subjects.html
View file @
f54704fc
...
...
@@ -4,6 +4,7 @@
{% block nav-subjects %}
<li
class=
"active"
><a
href=
"/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-search-subjects %}
<li><a
href=
"/subjects"
>
Available Subjects
</a></li>
{% endblock %}
{% block nav-pending-subjects %}
<li
><a
href=
"/pending_subjects"
>
Pending Requests
</a></li>
{% endblock %}
{% block body%}
<div
class=
"container"
style=
"margin-top:50px;"
>
<div
style=
"width: 70%; margin: auto;"
>
...
...
@@ -14,15 +15,26 @@
<tr>
<th
style=
"text-align: center;"
>
Course ID
</th>
<th
style=
"text-align: center;"
>
Course Name
</th>
<th
style=
"text-align: center;"
>
Professor
</th>
<th
style=
"text-align: center;"
>
Action
</th>
<!-- <th>Professor</th> -->
</tr>
</thead>
<tbody>
{% for sub_stu in subject_student %}
{% for sub_stud in subject_student %}
{% if sub_stud.is_accepted %}
<tr>
<td
style=
"text-align: center;"
><a
href=
"/topics/{{ sub_stu.subject.sub_code }}"
>
{{ sub_stu.subject.sub_code }}
</a></td>
<td
style=
"text-align: center;"
>
{{ sub_stu.subject.sub_name }}
</td>
<td
style=
"text-align: center;"
><a
href=
"/topics/{{ sub_stud.subject.sub_code }}"
>
{{ sub_stud.subject.sub_code }}
</a></td>
<td
style=
"text-align: center;"
>
{{ sub_stud.subject.sub_name }}
</td>
<td
style=
"text-align: center;"
>
{{ sub_stud.subject.prof.fname }} {{ sub_stud.subject.prof.lname }}
</td>
<td
style=
"text-align: center;"
>
<a
href=
"/withdraw_subject/{{sub_stud.subject.sub_code}}"
>
<button
class=
"btn btn-success"
>
Withdraw
</button>
</a>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
...
...
discussion/views.py
View file @
f54704fc
...
...
@@ -20,6 +20,9 @@ def login(request):
# request.session['session_context']['lname'] = login.lname
request
.
session
[
'session_context'
]
=
login
.
pid
if
(
login
.
is_prof
==
True
):
return
redirect
(
'/prof'
)
return
redirect
(
'/'
)
except
:
...
...
@@ -60,6 +63,7 @@ def signup(request):
def
default
(
request
):
is_prof
=
False
try
:
context
=
request
.
session
[
'session_context'
]
except
:
...
...
@@ -67,6 +71,93 @@ def default(request):
return
render
(
request
,
'default.html'
,{
'context'
:
context
})
def
prof_home
(
request
):
try
:
context
=
request
.
session
[
'session_context'
]
except
:
context
=
None
return
render
(
request
,
'prof_home.html'
,{
'context'
:
context
})
def
prof_subjects
(
request
):
context
=
request
.
session
[
'session_context'
]
try
:
prof
=
Person
.
objects
.
get
(
pid
=
context
)
subjects
=
Subject
.
objects
.
filter
(
prof
=
prof
)
except
:
subjects
=
None
return
render
(
request
,
"prof_subjects.html"
,{
'subjects'
:
subjects
,
'context'
:
context
})
def
student_list
(
request
,
sub_code
):
context
=
request
.
session
[
'session_context'
]
sub_studs
=
None
try
:
prof
=
Person
.
objects
.
get
(
pid
=
context
)
subject
=
Subject
.
objects
.
get
(
prof
=
prof
,
sub_code
=
sub_code
)
sub_studs
=
Subject_Student
.
objects
.
filter
(
subject
=
subject
)
except
:
sub_studs
=
None
return
render
(
request
,
"students_list.html"
,{
'subject'
:
subject
,
'context'
:
context
,
'sub_studs'
:
sub_studs
})
def
accept_student
(
request
,
sub_code
,
pid
):
context
=
request
.
session
[
'session_context'
]
try
:
sub_stud_to_accept
=
Subject_Student
.
objects
.
get
(
student
=
Person
.
objects
.
get
(
pid
=
pid
),
subject
=
Subject
.
objects
.
get
(
sub_code
=
sub_code
))
sub_stud_to_accept
.
is_accepted
=
True
sub_stud_to_accept
.
save
()
except
Exception
as
e
:
print
(
e
)
return
redirect
(
'/prof/student_list/'
+
sub_code
)
def
request_subject
(
request
,
sub_code
):
context
=
request
.
session
[
'session_context'
]
try
:
subject
=
Subject
.
objects
.
get
(
sub_code
=
sub_code
)
student
=
Person
.
objects
.
get
(
pid
=
context
)
sub_stud
=
Subject_Student
(
subject
=
subject
,
student
=
student
)
sub_stud
.
save
()
except
Exception
as
e
:
print
(
e
)
return
redirect
(
'/available_subjects'
)
def
reject_student
(
request
,
sub_code
,
pid
):
context
=
request
.
session
[
'session_context'
]
try
:
Subject_Student
.
objects
.
get
(
student
=
Person
.
objects
.
get
(
pid
=
pid
),
subject
=
Subject
.
objects
.
get
(
sub_code
=
sub_code
))
.
delete
()
except
Exception
as
e
:
print
(
e
)
return
redirect
(
'/prof/student_list/'
+
sub_code
)
def
reject_subject
(
request
,
sub_code
):
context
=
request
.
session
[
'session_context'
]
try
:
Subject_Student
.
objects
.
get
(
student
=
Person
.
objects
.
get
(
pid
=
context
),
subject
=
Subject
.
objects
.
get
(
sub_code
=
sub_code
))
.
delete
()
except
Exception
as
e
:
print
(
e
)
return
redirect
(
'/pending_subjects'
)
def
withdraw_subject
(
request
,
sub_code
):
context
=
request
.
session
[
'session_context'
]
try
:
Subject_Student
.
objects
.
get
(
student
=
Person
.
objects
.
get
(
pid
=
context
),
subject
=
Subject
.
objects
.
get
(
sub_code
=
sub_code
))
.
delete
()
except
Exception
as
e
:
print
(
e
)
return
redirect
(
'/subjects'
)
def
show_subjects
(
request
):
context
=
request
.
session
[
'session_context'
]
try
:
...
...
@@ -80,15 +171,43 @@ def show_all_subjects(request):
context
=
request
.
session
[
'session_context'
]
subjects
=
Subject
.
objects
.
all
()
sub_studs
=
Subject_Student
.
objects
.
filter
(
student
=
Person
.
objects
.
get
(
pid
=
context
))
my_subs
=
[]
for
sub_stud
in
sub_studs
:
my_subs
.
append
(
sub_stud
.
subject
.
sub_code
)
subjects
=
subjects
.
exclude
(
sub_code__in
=
my_subs
)
return
render
(
request
,
"available_subjects.html"
,{
'subjects'
:
subjects
,
'context'
:
context
})
def
show_pending_subjects
(
request
):
context
=
request
.
session
[
'session_context'
]
sub_studs
=
Subject_Student
.
objects
.
filter
(
student
=
Person
.
objects
.
get
(
pid
=
context
))
return
render
(
request
,
"pending_subjects.html"
,{
'sub_studs'
:
sub_studs
,
'context'
:
context
})
def
show_topics
(
request
,
id
):
context
=
request
.
session
[
'session_context'
]
is_prof
=
False
try
:
subject
=
Subject
.
objects
.
get
(
sub_code
=
id
)
except
:
return
redirect
(
'/'
)
try
:
person
=
Person
.
objects
.
get
(
pid
=
context
)
is_prof
=
person
.
is_prof
except
Exception
as
e
:
print
(
e
)
if
is_prof
:
topics
=
Topic
.
objects
.
filter
(
subject
=
subject
,
is_prof_included
=
True
)
else
:
topics
=
Topic
.
objects
.
filter
(
subject
=
subject
)
if
request
.
method
==
"POST"
:
form
=
TopicForm
(
request
.
POST
)
...
...
@@ -103,7 +222,11 @@ def show_topics(request, id):
pass
else
:
form
=
TopicForm
()
return
render
(
request
,
'discussion_topics.html'
,{
'form'
:
form
,
'sub_code'
:
id
,
'topics'
:
topics
,
'context'
:
context
})
if
is_prof
:
return
render
(
request
,
'prof_discussion_topics.html'
,{
'form'
:
form
,
'sub_code'
:
id
,
'topics'
:
topics
,
'context'
:
context
,
'is_prof'
:
is_prof
})
else
:
return
render
(
request
,
'discussion_topics.html'
,{
'form'
:
form
,
'sub_code'
:
id
,
'topics'
:
topics
,
'context'
:
context
,
'is_prof'
:
is_prof
})
def
show_threads
(
request
,
id
):
context
=
request
.
session
[
'session_context'
]
...
...
djangodb
View file @
f54704fc
No preview for this file type
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