retest
This commit is contained in:
parent
08de8a05f8
commit
38fa241e90
@ -1,5 +1,6 @@
|
|||||||
from Main.models import Solution
|
from Main.models import Solution
|
||||||
from SprintLib.BaseView import BaseView, AccessError
|
from SprintLib.BaseView import BaseView, AccessError
|
||||||
|
from SprintLib.utils import send_testing
|
||||||
|
|
||||||
|
|
||||||
class SolutionView(BaseView):
|
class SolutionView(BaseView):
|
||||||
@ -8,8 +9,25 @@ class SolutionView(BaseView):
|
|||||||
endpoint = "solution"
|
endpoint = "solution"
|
||||||
solution: Solution
|
solution: Solution
|
||||||
|
|
||||||
def pre_handle(self):
|
def check_admin(self):
|
||||||
|
user = self.request.user
|
||||||
if self.request.user.is_superuser:
|
if self.request.user.is_superuser:
|
||||||
|
return True
|
||||||
|
if self.solution.task.creator == user or user.username in self.solution.task.editors:
|
||||||
|
return True
|
||||||
|
if self.solution.set:
|
||||||
|
if self.solution.set.creator == user or user.username in self.solution.set.editors:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def pre_handle(self):
|
||||||
|
if self.check_admin():
|
||||||
return
|
return
|
||||||
if self.solution.user != self.request.user:
|
if self.solution.user != self.request.user:
|
||||||
raise AccessError()
|
raise AccessError()
|
||||||
|
|
||||||
|
def post_retest(self):
|
||||||
|
if not self.check_admin():
|
||||||
|
return "/"
|
||||||
|
send_testing(self.solution)
|
||||||
|
return "/solution?solution_id=" + str(self.solution.id)
|
||||||
|
@ -5,8 +5,7 @@ from zipfile import ZipFile
|
|||||||
from Main.models import Solution, Progress, SolutionFile, SetTask, Task, Set
|
from Main.models import Solution, Progress, SolutionFile, SetTask, Task, Set
|
||||||
from SprintLib.BaseView import BaseView, AccessError
|
from SprintLib.BaseView import BaseView, AccessError
|
||||||
from SprintLib.language import languages
|
from SprintLib.language import languages
|
||||||
from SprintLib.queue import send_to_queue
|
from SprintLib.utils import write_bytes, send_testing
|
||||||
from SprintLib.utils import write_bytes
|
|
||||||
|
|
||||||
|
|
||||||
class TaskView(BaseView):
|
class TaskView(BaseView):
|
||||||
@ -55,7 +54,7 @@ class TaskView(BaseView):
|
|||||||
solution=self.solution,
|
solution=self.solution,
|
||||||
fs_id=fs_id,
|
fs_id=fs_id,
|
||||||
)
|
)
|
||||||
self.send_testing()
|
send_testing(self.solution)
|
||||||
return ("/task?setTask_id=" + str(self.setTask.id)) if self.set else ("/task?task_id=" + str(self.task.id))
|
return ("/task?setTask_id=" + str(self.setTask.id)) if self.set else ("/task?task_id=" + str(self.task.id))
|
||||||
|
|
||||||
def post_1(self):
|
def post_1(self):
|
||||||
@ -81,10 +80,5 @@ class TaskView(BaseView):
|
|||||||
solution=self.solution,
|
solution=self.solution,
|
||||||
fs_id=fs_id,
|
fs_id=fs_id,
|
||||||
)
|
)
|
||||||
self.send_testing()
|
send_testing(self.solution)
|
||||||
return ("/task?setTask_id=" + str(self.setTask.id)) if self.set else ("/task?task_id=" + str(self.task.id))
|
return ("/task?setTask_id=" + str(self.setTask.id)) if self.set else ("/task?task_id=" + str(self.task.id))
|
||||||
|
|
||||||
def send_testing(self):
|
|
||||||
if self.solution.set is not None and len(self.solution.set.checkers.all()) != 0:
|
|
||||||
return
|
|
||||||
send_to_queue("test", {"id": self.solution.id})
|
|
||||||
|
@ -5,6 +5,7 @@ from django.contrib.auth.models import User
|
|||||||
from django.core.management import BaseCommand
|
from django.core.management import BaseCommand
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import django.db
|
import django.db
|
||||||
|
import django.db.utils
|
||||||
from pika.adapters.utils.connection_workflow import AMQPConnectorException
|
from pika.adapters.utils.connection_workflow import AMQPConnectorException
|
||||||
|
|
||||||
from Sprint import settings
|
from Sprint import settings
|
||||||
@ -35,7 +36,7 @@ class MessagingSupport(BaseCommand):
|
|||||||
try:
|
try:
|
||||||
self.process(data)
|
self.process(data)
|
||||||
print("Process finished successfully")
|
print("Process finished successfully")
|
||||||
except (psycopg2.OperationalError, django.db.OperationalError):
|
except (psycopg2.OperationalError, django.db.OperationalError, django.db.utils.OperationalError):
|
||||||
print("Failed to connect to database, restarting...")
|
print("Failed to connect to database, restarting...")
|
||||||
send_to_queue(self.queue_name, data)
|
send_to_queue(self.queue_name, data)
|
||||||
raise
|
raise
|
||||||
|
@ -6,6 +6,7 @@ from django.core.management import BaseCommand
|
|||||||
from requests import get, post
|
from requests import get, post
|
||||||
|
|
||||||
from Sprint import settings
|
from Sprint import settings
|
||||||
|
from SprintLib.queue import send_to_queue
|
||||||
|
|
||||||
|
|
||||||
def write_bytes(data: bytes):
|
def write_bytes(data: bytes):
|
||||||
@ -67,3 +68,9 @@ class LoopWorker(BaseCommand):
|
|||||||
while True:
|
while True:
|
||||||
self.go()
|
self.go()
|
||||||
sleep(self.sleep_period)
|
sleep(self.sleep_period)
|
||||||
|
|
||||||
|
|
||||||
|
def send_testing(solution):
|
||||||
|
if solution.set is not None and len(solution.set.checkers.all()) != 0:
|
||||||
|
return
|
||||||
|
send_to_queue("test", {"id": solution.id})
|
||||||
|
@ -62,7 +62,11 @@
|
|||||||
Результат
|
Результат
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="badge bg-{% if solution.result == in_queue_status %}secondary{% else %}{% if solution.result == ok_status %}success{% else %}{% if solution.result|startswith:testing_status %}info{% else %}danger{% endif %}{% endif %}{% endif %}">{% if solution.result == testing_status %}<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="circle-notch" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="width: 20px;" class="svg-inline--fa fa-circle-notch fa-w-16 fa-spin fa-lg"><path fill="currentColor" d="M288 39.056v16.659c0 10.804 7.281 20.159 17.686 23.066C383.204 100.434 440 171.518 440 256c0 101.689-82.295 184-184 184-101.689 0-184-82.295-184-184 0-84.47 56.786-155.564 134.312-177.219C216.719 75.874 224 66.517 224 55.712V39.064c0-15.709-14.834-27.153-30.046-23.234C86.603 43.482 7.394 141.206 8.003 257.332c.72 137.052 111.477 246.956 248.531 246.667C393.255 503.711 504 392.788 504 256c0-115.633-79.14-212.779-186.211-240.236C302.678 11.889 288 23.456 288 39.056z" class=""></path></svg> {% endif %}{{ solution.result }}</span>
|
<form method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="action" value="retest">
|
||||||
|
<button disabled class="badge bg-{% if solution.result == in_queue_status %}secondary{% else %}{% if solution.result == ok_status %}success{% else %}{% if solution.result|startswith:testing_status %}info{% else %}danger{% endif %}{% endif %}{% endif %}">{% if solution.result == testing_status %}<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="circle-notch" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="width: 20px;" class="svg-inline--fa fa-circle-notch fa-w-16 fa-spin fa-lg"><path fill="currentColor" d="M288 39.056v16.659c0 10.804 7.281 20.159 17.686 23.066C383.204 100.434 440 171.518 440 256c0 101.689-82.295 184-184 184-101.689 0-184-82.295-184-184 0-84.47 56.786-155.564 134.312-177.219C216.719 75.874 224 66.517 224 55.712V39.064c0-15.709-14.834-27.153-30.046-23.234C86.603 43.482 7.394 141.206 8.003 257.332c.72 137.052 111.477 246.956 248.531 246.667C393.255 503.711 504 392.788 504 256c0-115.633-79.14-212.779-186.211-240.236C302.678 11.889 288 23.456 288 39.056z" class=""></path></svg> {% endif %}{{ solution.result }}</button>{% if solution.task.creator == user or user.username in solution.task.editors or solution.set and solution.set.creator == user or solution.set and user.username in solution.set.editors %} <button class="btn btn-secondary"><i class="fa fa-undo"></i></button> {% endif %}
|
||||||
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
Reference in New Issue
Block a user