Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS699_project
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
YADNYESH SANTOSH PATIL
CS699_project
Commits
8e866a62
Commit
8e866a62
authored
Nov 27, 2019
by
ASHISH KUMAR GOYAL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define User Groups
parent
61ee02cf
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
47 additions
and
5 deletions
+47
-5
README.md
README.md
+4
-0
hostel_mess/db.sqlite3
hostel_mess/db.sqlite3
+0
-0
hostel_mess/hostel_mess/__pycache__/settings.cpython-36.pyc
hostel_mess/hostel_mess/__pycache__/settings.cpython-36.pyc
+0
-0
hostel_mess/hostel_mess/settings.py
hostel_mess/hostel_mess/settings.py
+2
-1
hostel_mess/templates/login.html
hostel_mess/templates/login.html
+1
-1
hostel_mess/usermgmt/__pycache__/urls.cpython-36.pyc
hostel_mess/usermgmt/__pycache__/urls.cpython-36.pyc
+0
-0
hostel_mess/usermgmt/__pycache__/utils.cpython-36.pyc
hostel_mess/usermgmt/__pycache__/utils.cpython-36.pyc
+0
-0
hostel_mess/usermgmt/__pycache__/views.cpython-36.pyc
hostel_mess/usermgmt/__pycache__/views.cpython-36.pyc
+0
-0
hostel_mess/usermgmt/urls.py
hostel_mess/usermgmt/urls.py
+4
-1
hostel_mess/usermgmt/utils.py
hostel_mess/usermgmt/utils.py
+20
-0
hostel_mess/usermgmt/views.py
hostel_mess/usermgmt/views.py
+16
-2
No files found.
README.md
View file @
8e866a62
...
...
@@ -4,6 +4,10 @@ superuser credentials:
username- sysad
password- messadmin
Mess manager credentials:
username- h4_manager
password- messofh4
--STUDENT---
viewreq.html = view status of requests made by students (rebates request table to be added) also the homepage for students
...
...
hostel_mess/db.sqlite3
View file @
8e866a62
No preview for this file type
hostel_mess/hostel_mess/__pycache__/settings.cpython-36.pyc
View file @
8e866a62
No preview for this file type
hostel_mess/hostel_mess/settings.py
View file @
8e866a62
...
...
@@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import
os
# from django_auth_ldap.config import LDAPSearch
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
...
...
@@ -127,6 +127,7 @@ STATIC_ROOT = os.path.join(BASE_DIR,'static')
LOGIN_URL
=
'/user/login/'
LOGIN_REDIRECT_URL
=
'/user/'
# AUTHENTICATION_BACKENDS = ["django_auth_ldap.backend.LDAPBackend"]
# AUTH_LDAP_SERVER_URI = "ldap://ldap.iitb.ac.in"
# AUTH_LDAP_ALWAYS_UPDATE_USER = False
...
...
hostel_mess/templates/login.html
View file @
8e866a62
...
...
@@ -44,7 +44,7 @@
</div>
<form
class=
"user"
action=
"{% url 'login' %}"
method=
"POST"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"next"
value=
"{{ request.GET.next }}"
/>
<input
type=
"hidden"
id=
"next"
name=
"next"
value=
"{{ request.GET.next }}"
/>
<div
class=
"form-group text-danger font-weight-bold"
>
<label
id=
'error_msg'
>
{{ error_msg }}
</label>
</div>
...
...
hostel_mess/usermgmt/__pycache__/urls.cpython-36.pyc
View file @
8e866a62
No preview for this file type
hostel_mess/usermgmt/__pycache__/utils.cpython-36.pyc
0 → 100644
View file @
8e866a62
File added
hostel_mess/usermgmt/__pycache__/views.cpython-36.pyc
View file @
8e866a62
No preview for this file type
hostel_mess/usermgmt/urls.py
View file @
8e866a62
...
...
@@ -7,9 +7,12 @@ from django.views.generic import RedirectView
urlpatterns
=
[
path
(
''
,
RedirectView
.
as_view
(
url
=
'login/'
),
name
=
'base'
),
path
(
'homepage/'
,
views
.
homepage_view
,
name
=
'homepage'
),
path
(
'login/'
,
views
.
login_view
,
name
=
'login'
),
path
(
'logout/'
,
views
.
logout_view
,
name
=
'logout'
),
path
(
'homepage/'
,
views
.
homepage_view
,
name
=
'homepage'
),
path
(
'student/'
,
views
.
student_homepage_view
,
name
=
'student-homepage'
),
path
(
'manager/'
,
views
.
manager_homepage_view
,
name
=
'manager-homepage'
),
path
(
'worker/'
,
views
.
worker_homepage_view
,
name
=
'worker-homepage'
),
## student functions below:
path
(
'rebate/'
,
views
.
rebate
),
...
...
hostel_mess/usermgmt/utils.py
0 → 100644
View file @
8e866a62
from
django.contrib.auth.models
import
User
,
Group
from
django.shortcuts
import
redirect
def
is_manager
(
user
):
return
user
.
groups
.
filter
(
name
=
'manager'
)
.
exists
()
def
is_worker
(
user
):
return
user
.
groups
.
filter
(
name
=
'worker'
)
.
exists
()
def
is_student
(
user
):
return
user
.
groups
.
filter
(
name
=
'student'
)
.
exists
()
def
homepage_redirect
(
request
):
user
=
request
.
user
if
is_manager
(
user
):
return
redirect
(
'manager-homepage'
)
elif
is_worker
(
user
):
return
redirect
(
'worker-homepage'
)
else
:
#is_student(user):
return
redirect
(
'student-homepage'
)
\ No newline at end of file
hostel_mess/usermgmt/views.py
View file @
8e866a62
...
...
@@ -3,12 +3,13 @@ from django.http import HttpResponse, HttpRequest
from
django.contrib.auth.models
import
User
from
django.contrib.auth
import
authenticate
,
login
,
logout
from
django.contrib.auth.decorators
import
login_required
from
usermgmt.utils
import
*
# Create your views here.
@
login_required
def
homepage_view
(
request
):
#get the user object and send in context
return
render
(
request
,
'viewreq.html'
,
context
=
None
)
return
homepage_redirect
(
request
)
def
login_view
(
request
):
"""View function for login page of site"""
...
...
@@ -25,10 +26,14 @@ def login_view(request):
username
=
request
.
POST
[
'username'
]
password
=
request
.
POST
[
'password'
]
user
=
authenticate
(
request
,
username
=
username
,
password
=
password
)
valuenext
=
request
.
POST
.
get
(
'next'
)
if
user
is
not
None
:
login
(
request
,
user
)
return
redirect
(
request
.
POST
.
get
(
'next'
,
'homepage'
))
if
valuenext
==
""
:
return
redirect
(
'homepage'
)
else
:
return
redirect
(
valuenext
)
else
:
return
render
(
request
,
'login.html'
,
context
=
{
'error_msg'
:
'Invalid Username/Password.'
})
# return render(request, 'viewreq.html', context=None)
...
...
@@ -40,6 +45,15 @@ def logout_view(request):
else
:
return
redirect
(
'base'
)
def
student_homepage_view
(
request
):
return
render
(
request
,
'viewreq.html'
,
context
=
None
)
def
manager_homepage_view
(
request
):
return
render
(
request
,
'viewreq.html'
,
context
=
None
)
def
worker_homepage_view
(
request
):
return
render
(
request
,
'viewreq.html'
,
context
=
None
)
def
rebate
(
request
):
return
render
(
request
,
'rebates.html'
)
...
...
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