Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
go
Commits
e15979df
Commit
e15979df
authored
Nov 09, 2016
by
Zosman
Browse files
This commit introduces the user management system i have created
parent
f82e3667
Pipeline
#434
passed with stage
in 7 minutes and 21 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
go/go/models.py
View file @
e15979df
...
...
@@ -19,7 +19,7 @@ class RegisteredUser(models.Model):
that that user is registered.
"""
# Is this User Blo
a
cked?
# Is this User Blocked?
blocked
=
models
.
BooleanField
(
default
=
False
)
# Let's associate a User to this RegisteredUser
...
...
go/go/templates/admin/useradmin.html
View file @
e15979df
...
...
@@ -24,6 +24,8 @@ SRCT Go • Administration Panel
</div>
</div>
<!-- TABLE 1 -->
<div
class=
"row"
>
<div
class=
"col-md-12"
>
...
...
@@ -75,5 +77,118 @@ SRCT Go • Administration Panel
</div>
</div>
<!-- TABLE 2 -->
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<h3>
Blocked Users
</h3>
<form
method=
"post"
action=
"useradmin"
>
{% csrf_token %}
<table
class=
"table table-striped table-hover "
>
<thead>
<tr>
<th>
Selected
</th>
<th>
Username
</th>
<th>
Full Name
</th>
<th>
Description
</th>
<th>
Is Blocked
</th>
</tr>
</thead>
<tbody>
{% for blockedUsers in blocked_users %}
<tr>
<td><input
type=
"checkbox"
name=
"username"
value=
{{
blockedUsers.user
}}
></td>
<td>
{{ blockedUsers.user }}
</td>
<td>
{{ blockedUsers.full_name }}
</td>
<td>
{{ blockedUsers.description|default:"No description provided" }}
</td>
<td>
{{ blockedUsers.blocked }}
</td>
</tr>
{% empty %}
<tr>
<td>
none
</td>
<td>
none
</td>
<td>
none
</td>
<td>
none
</td>
<td>
none
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div
class=
"form-group"
>
<!-- <input type="submit" name="_approve" value="Approve" class="btn btn-primary btn-sm"> -->
<!-- <input type="submit" name="_deny" value="Deny" class="btn btn-danger btn-sm"> -->
<input
type=
"submit"
name=
"_unblock"
value=
"Un-Block"
class=
"btn btn-default btn-sm"
>
</div>
</form>
</div>
</div>
<!-- TABLE 3 -->
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<h3>
Current Users
</h3>
<form
method=
"post"
action=
"useradmin"
>
{% csrf_token %}
<table
class=
"table table-striped table-hover "
>
<thead>
<tr>
<th>
Selected
</th>
<th>
Username
</th>
<th>
Full Name
</th>
<th>
Description
</th>
<th>
Is Blocked
</th>
</tr>
</thead>
<tbody>
{% for currentUsers in current_users %}
<tr>
<td><input
type=
"checkbox"
name=
"username"
value=
{{
currentUsers.user
}}
></td>
<td>
{{ currentUsers.user }}
</td>
<td>
{{ currentUsers.full_name }}
</td>
<td>
{{ currentUsers.description|default:"No description provided" }}
</td>
<td>
{{ currentUsers.blocked }}
</td>
</tr>
{% empty %}
<tr>
<td>
none
</td>
<td>
none
</td>
<td>
none
</td>
<td>
none
</td>
<td>
none
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div
class=
"form-group"
>
<!-- <input type="submit" name="_approve" value="Approve" class="btn btn-primary btn-sm"> -->
<input
type=
"submit"
name=
"_remove"
value=
"Remove"
class=
"btn btn-danger btn-sm"
>
<input
type=
"submit"
name=
"_block"
value=
"Block"
class=
"btn btn-default btn-sm"
style=
"background-color: black; color: white;"
>
<!-- <input type="submit" name="_unblock" value="Un-Block" class="btn btn-default btn-sm"> -->
</div>
</form>
</div>
</div>
{% endblock %}
go/go/views.py
View file @
e15979df
...
...
@@ -16,9 +16,9 @@ from go.forms import URLForm, SignupForm
# Other Imports
from
datetime
import
timedelta
requestObject
=
request
.
RegisteredUser
.
objects
.
get
(
user__username__exact
=
user
)
if
requestObject
.
user
.
registereduser
.
blocked
!=
False
raise
PermissionDenied
()
#
requestObject = request.RegisteredUser.objects.get(user__username__exact=user)
#
if requestObject.user.registereduser.blocked != False
#
raise PermissionDenied()
def
index
(
request
):
...
...
@@ -344,9 +344,57 @@ def useradmin(request):
[
user_mail
]
)
# toblock.user.delete()
toblock
.
user
.
registereduser
.
blocked
=
True
toblock
.
blocked
=
True
toblock
.
approved
=
False
toblock
.
save
()
elif
'_unblock'
in
request
.
POST
:
for
name
in
userlist
:
toUNblock
=
RegisteredUser
.
objects
.
get
(
user__username__exact
=
name
)
if
settings
.
EMAIL_HOST
and
settings
.
EMAIL_PORT
:
user_mail
=
toUNblock
.
user
.
username
+
settings
.
EMAIL_DOMAIN
send_mail
(
'Your Account has been Blocked!'
,
######################
'Hey there %s,
\n\n
'
'The Go admins have reviewed your application and have '
'unblocked you from using Go.
\n\n
'
'Congratulations! '
'- Go Admins'
%
(
str
(
toblock
.
full_name
)),
######################
settings
.
EMAIL_FROM
,
[
user_mail
]
)
# toblock.user.delete()
toUNblock
.
blocked
=
False
toUNblock
.
approved
=
True
toUNblock
.
save
()
elif
'_remove'
in
request
.
POST
:
for
name
in
userlist
:
toremove
=
RegisteredUser
.
objects
.
get
(
user__username__exact
=
name
)
if
settings
.
EMAIL_HOST
and
settings
.
EMAIL_PORT
:
user_mail
=
toremove
.
user
.
username
+
settings
.
EMAIL_DOMAIN
send_mail
(
'Your Account has been Deleted!'
,
######################
'Hey there %s,
\n\n
'
'The Go admins have decided to remove you from Go.
\n\n
'
'Please reach out to srct@gmu.edu to appeal '
'this decision.
\n\n
'
'- Go Admins'
%
(
str
(
toremove
.
full_name
)),
######################
settings
.
EMAIL_FROM
,
[
user_mail
]
)
toremove
.
user
.
delete
()
need_approval
=
RegisteredUser
.
objects
.
filter
(
registered
=
True
).
filter
(
approved
=
False
)
current_users
=
RegisteredUser
.
objects
.
filter
(
approved
=
True
).
filter
(
registered
=
True
)
blocked_users
=
RegisteredUser
.
objects
.
filter
(
blocked
=
True
)
return
render
(
request
,
'admin/useradmin.html'
,
{
'need_approval'
:
need_approval
'need_approval'
:
need_approval
,
'current_users'
:
current_users
,
'blocked_users'
:
blocked_users
},
)
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