Have enabled / approver flags for doing admin things
This commit is contained in:
1 parent
7d63b6b917
commit
290b729325
4 files changed
+24
-7
No files matched your search
+6
-4
@@ -26,10 +26,12 @@ class Engine(Model):
|
||||
|
||||
class Profile(Model):
|
||||
|
||||
user = OneToOneField(User, on_delete=CASCADE)
|
||||
games = IntegerField(default=0)
|
||||
tests = IntegerField(default=0)
|
||||
repo = CharField(max_length=256)
|
||||
user = OneToOneField(User, on_delete=CASCADE)
|
||||
games = IntegerField(default=0)
|
||||
tests = IntegerField(default=0)
|
||||
repo = CharField(max_length=256)
|
||||
enabled = BooleanField(default=False)
|
||||
approver = BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.user.__str__()
|
||||
|
||||
+12
-1
@@ -140,6 +140,12 @@ def newTest(request):
|
||||
return render(request, 'newTest.html', {"user" : request.user})
|
||||
|
||||
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
|
||||
test = OpenBench.utils.newTest(request)
|
||||
|
||||
@@ -172,10 +178,15 @@ def viewTest(request, id):
|
||||
except Exception as error:
|
||||
return index(request, error=str(error))
|
||||
|
||||
@staff_member_required
|
||||
@login_required
|
||||
def approveTest(request, id):
|
||||
|
||||
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
|
||||
test = Test.objects.get(id=id)
|
||||
test.approved = True
|
||||
|
||||
@@ -10,14 +10,18 @@
|
||||
<th>Username</th>
|
||||
<th>Games</th>
|
||||
<th>Tests</th>
|
||||
<th>Repository</th>
|
||||
<th>Repo</th>
|
||||
<th>Enabled</th>
|
||||
<th>Approver</th>
|
||||
</tr>
|
||||
{% for profile in profiles %}
|
||||
<tr>
|
||||
<td>{{profile.user.username}}</td>
|
||||
<td><a href="/viewUser/{{profile.user.username}}">{{profile.user.username}}</a></td>
|
||||
<td>{{profile.games}}</td>
|
||||
<td>{{profile.tests}}</td>
|
||||
<td>{{profile.repo}}</td>
|
||||
<td>{{profile.enabled}}</td>
|
||||
<td>{{profile.approver}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<table>
|
||||
|
||||
BIN
Binary file not shown.
Reference in new issue
Block a user