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
e205f4ec
Commit
e205f4ec
authored
Nov 05, 2019
by
AMAN MORESHWAR JANGDE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Discussion thread flow impl
parent
e8cda389
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
315 additions
and
27 deletions
+315
-27
.gitignore
.gitignore
+1
-0
coursebook/urls.py
coursebook/urls.py
+4
-1
discussion/forms.py
discussion/forms.py
+20
-2
discussion/migrations/0001_initial.py
discussion/migrations/0001_initial.py
+2
-1
discussion/models.py
discussion/models.py
+2
-1
discussion/static/css/login.css
discussion/static/css/login.css
+57
-0
discussion/static/css/signup.css
discussion/static/css/signup.css
+32
-0
discussion/templates/base.html
discussion/templates/base.html
+27
-9
discussion/templates/discussion_thread.html
discussion/templates/discussion_thread.html
+4
-1
discussion/templates/discussion_topics.html
discussion/templates/discussion_topics.html
+4
-1
discussion/templates/login.html
discussion/templates/login.html
+41
-0
discussion/templates/signup.html
discussion/templates/signup.html
+42
-0
discussion/templates/subjects.html
discussion/templates/subjects.html
+4
-1
discussion/views.py
discussion/views.py
+75
-10
djangodb
djangodb
+0
-0
No files found.
.gitignore
View file @
e205f4ec
*.sqlite3
\ No newline at end of file
coursebook/urls.py
View file @
e205f4ec
...
...
@@ -32,9 +32,12 @@ urlpatterns = [
path
(
'delete/<int:id>'
,
views
.
destroy
),
path
(
''
,
views
.
default
),
path
(
'subjects/
<int:id>
'
,
views
.
show_subjects
),
path
(
'subjects/'
,
views
.
show_subjects
),
path
(
'topics/<int:id>'
,
views
.
show_topics
),
path
(
'threads/<int:id>'
,
views
.
show_threads
),
path
(
'login'
,
views
.
login
),
path
(
'signup'
,
views
.
signup
),
path
(
'logout'
,
views
.
logout
),
# path('add_thread/<int:id>', views.add_message),
]
discussion/forms.py
View file @
e205f4ec
from
django
import
forms
from
discussion.models
import
Employee
,
Thread
,
Topic
from
discussion.models
import
Employee
,
Thread
,
Topic
,
Person
class
EmployeeForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Employee
...
...
@@ -19,3 +19,21 @@ class TopicForm(forms.ModelForm):
model
=
Topic
fields
=
"__all__"
exclude
=
(
"subject"
,)
class
SignupForm
(
forms
.
ModelForm
):
pid
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'inp-field'
,
'placeholder'
:
'PID...'
}))
fname
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'inp-field'
,
'placeholder'
:
'First Name...'
}))
lname
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'inp-field'
,
'placeholder'
:
'Last name...'
}))
password
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'inp-field'
,
'placeholder'
:
'Password...'
}))
class
Meta
:
model
=
Person
fields
=
"__all__"
class
LoginForm
(
forms
.
ModelForm
):
pid
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'inp-field'
,
'placeholder'
:
'PID...'
}))
password
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'inp-field'
,
'placeholder'
:
'Password...'
}))
class
Meta
:
model
=
Person
fields
=
(
'pid'
,
'password'
)
\ No newline at end of file
discussion/migrations/0001_initial.py
View file @
e205f4ec
# Generated by Django 2.0.3 on 2019-11-0
2 18:12
# Generated by Django 2.0.3 on 2019-11-0
5 13:26
from
django.db
import
migrations
,
models
import
django.db.models.deletion
...
...
@@ -42,6 +42,7 @@ class Migration(migrations.Migration):
(
'pid'
,
models
.
CharField
(
max_length
=
20
)),
(
'fname'
,
models
.
CharField
(
max_length
=
20
)),
(
'lname'
,
models
.
CharField
(
max_length
=
20
)),
(
'password'
,
models
.
CharField
(
max_length
=
20
)),
(
'is_prof'
,
models
.
BooleanField
(
default
=
False
)),
],
options
=
{
...
...
discussion/models.py
View file @
e205f4ec
...
...
@@ -12,6 +12,7 @@ class Person(models.Model):
pid
=
models
.
CharField
(
max_length
=
20
)
fname
=
models
.
CharField
(
max_length
=
20
)
lname
=
models
.
CharField
(
max_length
=
20
)
password
=
models
.
CharField
(
max_length
=
20
)
is_prof
=
models
.
BooleanField
(
default
=
False
)
def
__str__
(
self
):
...
...
discussion/static/css/login.css
0 → 100644
View file @
e205f4ec
.login-form
{
border
:
3px
solid
#f1f1f1
;}
.inp-field
{
width
:
100%
;
padding
:
12px
20px
;
margin
:
8px
0
;
display
:
inline-block
;
border
:
1px
solid
#ccc
;
box-sizing
:
border-box
;
}
.login-button
{
background-color
:
#4CAF50
;
color
:
white
;
padding
:
14px
20px
;
margin
:
8px
0
;
border
:
none
;
cursor
:
pointer
;
width
:
100%
;
}
.login-button
:hover
{
opacity
:
0.8
;
}
.login-form-container
{
padding
:
16px
;
}
.alert
{
padding
:
20px
;
background-color
:
#f44336
;
/* Red */
color
:
white
;
margin-bottom
:
15px
;
}
/* The close button */
.closebtn
{
margin-left
:
15px
;
color
:
white
;
font-weight
:
bold
;
float
:
right
;
font-size
:
22px
;
line-height
:
20px
;
cursor
:
pointer
;
transition
:
0.3s
;
}
/* When moving the mouse over the close button */
.closebtn
:hover
{
color
:
black
;
}
discussion/static/css/signup.css
0 → 100644
View file @
e205f4ec
.signup-form
{
border
:
3px
solid
#f1f1f1
;}
.inp-field
{
width
:
100%
;
padding
:
12px
20px
;
margin
:
8px
0
;
display
:
inline-block
;
border
:
1px
solid
#ccc
;
box-sizing
:
border-box
;
}
.signup-button
{
background-color
:
#4CAF50
;
color
:
white
;
padding
:
14px
20px
;
margin
:
8px
0
;
border
:
none
;
cursor
:
pointer
;
width
:
100%
;
}
.signup-button
:hover
{
opacity
:
0.8
;
}
.signup-form-container
{
padding
:
16px
;
}
discussion/templates/base.html
View file @
e205f4ec
...
...
@@ -5,6 +5,8 @@
<link
rel=
"stylesheet"
href=
"{% static 'css/base.css' %}"
>
{% block style-discussion-thread %}{% endblock %}
{% block style-discussion-topics %}{% endblock %}
{% block style-login %}{% endblock %}
{% block style-signup %}{% endblock %}
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, shrink-to-fit=yes"
>
...
...
@@ -27,18 +29,34 @@
<nav
class=
"navbar navbar-inverse navbar-fixed-top"
>
<div
class=
"container-fluid"
>
<div
class=
"navbar-header"
>
<button
class=
"navbar-toggle"
data-toggle=
"collapse"
data-target=
"#mynavbar"
>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
</button>
<a
class=
"navbar-brand"
href=
"/"
>
Coursebook
</a>
</div>
<div
class=
"collapse navbar-collapse"
id=
"mynavbar"
>
<ul
class=
"nav navbar-nav"
>
<li
class=
"active"
>
{% block nav-home %}
<a
href=
"/"
>
Home
</a>
{% endblock %}
</li>
<li>
{% block nav-subjects %}
<a
href=
"/subjects/{{pid}}"
>
My Subjects
</a>
{% endblock %}
</li>
<li>
{% block nav-search-subjects %}
<a
href=
"/subjects/"
>
Search Subjects
</a>
{% endblock %}
</li>
{% block nav-home %}
<li
class=
"active"
><a
href=
"/"
>
Home
</a></li>
{% endblock %}
{% if context is not None %}
{% 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 %}
{% endif %}
</ul>
<ul
class=
"nav navbar-nav navbar-right"
>
<li><a
href=
"#"
><span
class=
"glyphicon glyphicon-user"
></span>
Sign Up
</a></li>
<li><a
href=
"#"
><span
class=
"glyphicon glyphicon-log-in"
></span>
Login
</a></li>
{% if context is None %}
{% 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>
<li><a
href=
"/logout"
><span
class=
"glyphicon glyphicon-log-in"
></span>
Logout
</a></li>
{% endif %}
</ul>
</div>
</div>
</nav>
{% endblock %}
...
...
discussion/templates/discussion_thread.html
View file @
e205f4ec
...
...
@@ -2,7 +2,10 @@
{% extends "base.html" %}
{% load static %}
{% block style-discussion-thread %}
<link
rel=
"stylesheet"
href=
"{% static 'css/discussion_thread.css' %}"
>
{% endblock %}
{% block nav-subjects %}
<a
href=
"/subjects/101"
>
My Subjects
</a>
{% 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 body%}
<div
class=
"container"
style=
"margin-top:50px"
>
<div
class=
"row"
>
...
...
discussion/templates/discussion_topics.html
View file @
e205f4ec
...
...
@@ -2,7 +2,10 @@
{% extends "base.html" %}
{% load static %}
{% block style-discussion-topics %}
<link
rel=
"stylesheet"
href=
"{% static 'css/discussion_topics.css' %}"
>
{% endblock %}
{% block nav-subjects %}
<a
href=
"/subjects/101"
>
My Subjects
</a>
{% 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 body%}
<div
class=
"container message-wrap "
style=
"margin-top:50px"
>
<p>
...
...
discussion/templates/login.html
0 → 100644
View file @
e205f4ec
{% extends "base.html" %}
{% load static %}
{% block style-login %}
<link
rel=
"stylesheet"
href=
"{% static 'css/login.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-signup %}
<li><a
href=
"/signup"
><span
class=
"glyphicon glyphicon-user"
></span>
Sign Up
</a></li>
{%endblock%}
{%block nav-login%}
<li
class=
"active"
><a
href=
"/login"
><span
class=
"glyphicon glyphicon-log-in"
></span>
Login
</a></li>
{%endblock%}
{% block body%}
<h2
style=
"margin-top:50px;text-align: center;"
>
Login
</h2>
<form
action=
"/login"
method=
"post"
class=
"login-form"
>
{% csrf_token %}
<div
class=
"login-form-container"
>
<label
for=
"uname"
><b>
Username
</b></label>
{{form.pid}}
<label
for=
"psw"
><b>
Password
</b></label>
{{form.password}}
<button
type=
"submit"
class=
"login-button"
>
Login
</button>
{% if invalid_user %}
<div
class=
"alert"
>
<span
class=
"closebtn"
onclick=
"this.parentElement.style.display='none';"
>
×
</span>
Invalid User
</div>
{% endif %}
</div>
</form>
{% endblock %}
discussion/templates/signup.html
0 → 100644
View file @
e205f4ec
{% extends "base.html" %}
{% load static %}
{% block style-signup %}
<link
rel=
"stylesheet"
href=
"{% static 'css/signup.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-signup %}
<li
class=
"active"
><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%}
{% block body%}
<h2
style=
"margin-top:50px;text-align:center;"
>
Signup
</h2>
<form
action=
"/signup"
method=
"post"
class=
"signup-form"
>
{% csrf_token %}
<div
class=
"signup-form-container"
>
<label
for=
"uname"
><b>
ID
</b></label>
{{form.pid}}
<label
for=
"psw"
><b>
Password
</b></label>
{{form.password}}
<label
for=
"psw"
><b>
First Name
</b></label>
{{form.fname}}
<label
for=
"psw"
><b>
Last Name
</b></label>
{{form.lname}}
<label
for=
"psw"
><b>
Are you Proff?
</b></label>
{{form.is_prof}}
<button
type=
"submit"
class=
"signup-button"
>
signup
</button>
</div>
</form>
{% endblock %}
discussion/templates/subjects.html
View file @
e205f4ec
{% extends "base.html" %}
{% block nav-subjects %}
<a
href=
"/subjects/101"
>
My Subjects
</a>
{% endblock %}
{% block nav-home %}
<li><a
href=
"/"
>
Home
</a></li>
{% endblock %}
{% block nav-subjects %}
<li
class=
"active"
><a
href=
"/subjects"
>
My Subjects
</a></li>
{% endblock %}
{% block nav-search-subjects %}
<li><a
href=
"/subjects"
>
Search Subjects
</a></li>
{% endblock %}
{% block body%}
<div
class=
"container"
style=
"margin-top:50px"
>
<h2>
My Courses
</h2>
...
...
discussion/views.py
View file @
e205f4ec
from
django.shortcuts
import
render
,
redirect
from
discussion.forms
import
EmployeeForm
,
ThreadForm
,
TopicForm
from
discussion.models
import
Employee
,
Subject_Student
,
Person
,
Subject
,
Topic
,
Thread
from
discussion.forms
import
EmployeeForm
,
ThreadForm
,
TopicForm
,
SignupForm
,
LoginForm
from
discussion.models
import
Employee
,
Subject_Student
,
Person
,
Subject
,
Topic
,
Thread
,
Person
# Create your views here.
def
emp
(
request
):
if
request
.
method
==
"POST"
:
...
...
@@ -33,18 +33,82 @@ def destroy(request, id):
return
redirect
(
"/show"
)
def
login
(
request
):
invalid_user
=
False
if
request
.
method
==
"POST"
:
form
=
LoginForm
(
request
.
POST
)
if
form
.
is_valid
():
try
:
form_pid
=
form
.
cleaned_data
.
get
(
"pid"
)
form_pswd
=
form
.
cleaned_data
.
get
(
"password"
)
# print (form_pid)
login
=
Person
.
objects
.
get
(
pid
=
form_pid
,
password
=
form_pswd
)
# print (login)
# topic.subject = subject
# request.session['session_context']['fname'] = login.fname
# request.session['session_context']['lname'] = login.lname
request
.
session
[
'session_context'
]
=
login
.
pid
return
redirect
(
'/'
)
except
:
invalid_user
=
True
else
:
invalid_user
=
True
else
:
form
=
LoginForm
()
# return render(request,'signup.html',{'form':form})
return
render
(
request
,
'login.html'
,
{
'form'
:
form
,
'invalid_user'
:
invalid_user
})
def
logout
(
request
):
try
:
del
request
.
session
[
'session_context'
]
except
:
pass
return
render
(
request
,
'base.html'
)
def
signup
(
request
):
if
request
.
method
==
"POST"
:
form
=
SignupForm
(
request
.
POST
)
if
form
.
is_valid
():
try
:
signup
=
form
.
save
(
commit
=
False
)
# topic.subject = subject
form
.
save
()
return
redirect
(
'/login'
)
except
:
pass
else
:
form
=
SignupForm
()
return
render
(
request
,
'signup.html'
,{
'form'
:
form
})
def
default
(
request
):
return
render
(
request
,
'base.html'
,{
'pid'
:
101
})
try
:
context
=
request
.
session
[
'session_context'
]
except
:
context
=
None
return
render
(
request
,
'base.html'
,{
'context'
:
context
})
def
show_subjects
(
request
,
id
):
def
show_subjects
(
request
):
context
=
request
.
session
[
'session_context'
]
try
:
person
=
Person
.
objects
.
get
(
pid
=
id
)
person
=
Person
.
objects
.
get
(
pid
=
context
)
except
:
return
redirect
(
'/'
)
subject_student
=
Subject_Student
.
objects
.
filter
(
student
=
person
)
return
render
(
request
,
"subjects.html"
,{
'subject_student'
:
subject_student
})
return
render
(
request
,
"subjects.html"
,{
'subject_student'
:
subject_student
,
'context'
:
context
})
def
show_topics
(
request
,
id
):
context
=
request
.
session
[
'session_context'
]
try
:
subject
=
Subject
.
objects
.
get
(
sub_code
=
id
)
except
:
...
...
@@ -64,16 +128,17 @@ def show_topics(request, id):
pass
else
:
form
=
TopicForm
()
return
render
(
request
,
'discussion_topics.html'
,{
'form'
:
form
,
'sub_code'
:
id
,
'topics'
:
topics
})
return
render
(
request
,
'discussion_topics.html'
,{
'form'
:
form
,
'sub_code'
:
id
,
'topics'
:
topics
,
'context'
:
context
})
def
show_threads
(
request
,
id
):
context
=
request
.
session
[
'session_context'
]
try
:
topic
=
Topic
.
objects
.
get
(
id
=
id
)
except
:
return
redirect
(
'/'
)
threads
=
Thread
.
objects
.
filter
(
topic
=
topic
)
if
request
.
method
==
"POST"
:
person
=
Person
.
objects
.
get
(
pid
=
101
)
person
=
Person
.
objects
.
get
(
pid
=
context
)
form
=
ThreadForm
(
request
.
POST
)
if
form
.
is_valid
():
...
...
@@ -88,4 +153,4 @@ def show_threads(request, id):
pass
else
:
form
=
ThreadForm
()
return
render
(
request
,
'discussion_thread.html'
,{
'form'
:
form
,
'topic_id'
:
id
,
'threads'
:
threads
})
\ No newline at end of file
return
render
(
request
,
'discussion_thread.html'
,{
'form'
:
form
,
'topic_id'
:
id
,
'threads'
:
threads
,
'context'
:
context
})
\ No newline at end of file
djangodb
View file @
e205f4ec
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