-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews_tables.py
89 lines (71 loc) · 3.07 KB
/
views_tables.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from django_tables2 import tables, RequestConfig, columns
from django_tables2.utils import A
from django.utils.safestring import mark_safe
from django.utils.html import format_html
from django.urls import reverse
import django_tables2 as dt
from file_table.file_table import FileTable
from datetime import datetime
import os
import pwd
import itertools
class DockerImagesTable(dt.Table):
id = columns.Column()
tags = dt.Column()
comment = dt.Column()
def render_id(self, value):
return format_html('<input type="radio" name="environment_image" value="{0}" required id="id_environment_image_0">', value)
class SingularityImagesTable(dt.Table):
id = dt.Column(verbose_name=" ")
name = dt.Column()
features = dt.Column()
based_on = dt.Column()
def render_id(self, value):
return format_html('<input type="radio" name="environment_image" value="{0}" required id="id_environment_image_0">', value)
class SelectFileTable(FileTable):
selection = columns.Column(verbose_name="Selection", empty_values=())
def render_selection(self, value, record):
return format_html('<input type="radio" name="entry_path" value="{0}" required id="id_entry_path">', record['file_table_file'])
class JobFilesTable(FileTable):
actions = dt.Column(empty_values=())
def render_actions(self, value, record):
if record['file_table_type'] == "file":
file_id = record['file_table_id']
return format_html('<a href="download_file/{0}">Download</a>', file_id)
else:
return ""
class QueueTable(dt.Table):
class Meta:
template_name = 'django_tables2/bootstrap-responsive.html'
def __init__(self, *args, **kwargs):
self.login_user = kwargs.pop('user_logged_in')
super(QueueTable, self).__init__(*args, **kwargs)
def render_user_id(self, value):
return pwd.getpwuid(int(value)).pw_name
def render_submit_time(self, value):
return datetime.utcfromtimestamp(value).strftime('%Y-%m-%d %H:%M:%S')
def render_job_state(self, value):
color = "black"
if value == "RUNNING":
color = "green"
if value == "PENDING":
color = "gray"
if value == "COMPLETED":
color = "blue"
if value == "FAILED":
color = "red"
return mark_safe('<span style="color: %s"> %s </span>' % (color, value))
def render_actions(self, value, record):
if record['user_id'] == self.login_user:
href_details = reverse('details_job', args=[record['job_id']])
href_remove = reverse('remove_job', args=[record['job_id']])
return mark_safe('<a href="{}">Details</a> <a href={}>Remove</a>'.format(href_details, href_remove))
else:
return "--"
login_user = 0
job_id = dt.Column()
job_state = dt.Column()
account = dt.Column(verbose_name='Group')
user_id = dt.Column(verbose_name='User')
submit_time = dt.Column()
actions = dt.Column(empty_values=())