Have enabled / approver flags for doing admin things

This commit is contained in:
AndyGrant committed 2018-06-10 14:19:32 -04:00
1 parent 7d63b6b917
commit 290b729325
4 files changed
+24 -7

No files matched your search

+6 -4
View File
@@ -26,10 +26,12 @@ class Engine(Model):
class Profile(Model): class Profile(Model):
user = OneToOneField(User, on_delete=CASCADE) user = OneToOneField(User, on_delete=CASCADE)
games = IntegerField(default=0) games = IntegerField(default=0)
tests = IntegerField(default=0) tests = IntegerField(default=0)
repo = CharField(max_length=256) repo = CharField(max_length=256)
enabled = BooleanField(default=False)
approver = BooleanField(default=False)
def __str__(self): def __str__(self):
return self.user.__str__() return self.user.__str__()
+12 -1
View File
@@ -140,6 +140,12 @@ def newTest(request):
return render(request, 'newTest.html', {"user" : request.user}) return render(request, 'newTest.html', {"user" : request.user})
try: try:
# Throw out non-approved / disabled users
profile = Profile.objects.get(user=request.user)
if not profile.enabled:
raise Exception("Account not Enabled")
# Create test and verify fields # Create test and verify fields
test = OpenBench.utils.newTest(request) test = OpenBench.utils.newTest(request)
@@ -172,10 +178,15 @@ def viewTest(request, id):
except Exception as error: except Exception as error:
return index(request, error=str(error)) return index(request, error=str(error))
@staff_member_required @login_required
def approveTest(request, id): def approveTest(request, id):
try: try:
# Throw out users without approver status
profile = Profile.objects.get(user=request.user)
if not profile.approver:
raise Exception("No Approver Permissions on Account")
# Approve the provided test # Approve the provided test
test = Test.objects.get(id=id) test = Test.objects.get(id=id)
test.approved = True test.approved = True
+6 -2
View File
@@ -10,14 +10,18 @@
<th>Username</th> <th>Username</th>
<th>Games</th> <th>Games</th>
<th>Tests</th> <th>Tests</th>
<th>Repository</th> <th>Repo</th>
<th>Enabled</th>
<th>Approver</th>
</tr> </tr>
{% for profile in profiles %} {% for profile in profiles %}
<tr> <tr>
<td>{{profile.user.username}}</td> <td><a href="/viewUser/{{profile.user.username}}">{{profile.user.username}}</a></td>
<td>{{profile.games}}</td> <td>{{profile.games}}</td>
<td>{{profile.tests}}</td> <td>{{profile.tests}}</td>
<td>{{profile.repo}}</td> <td>{{profile.repo}}</td>
<td>{{profile.enabled}}</td>
<td>{{profile.approver}}</td>
</tr> </tr>
{% endfor %} {% endfor %}
<table> <table>
BIN
View File
Binary file not shown.