Commit 11305fea by Kálmán Viktor

request: make request table nicer

parent 9ed462b9
...@@ -61,6 +61,9 @@ class Request(TimeStampedModel): ...@@ -61,6 +61,9 @@ class Request(TimeStampedModel):
def get_readable_status(self): def get_readable_status(self):
return self.STATUSES[self.status] return self.STATUSES[self.status]
def get_readable_type(self):
return self.TYPES[self.type]
def get_request_icon(self): def get_request_icon(self):
return { return {
'resource': "tasks", 'resource': "tasks",
......
...@@ -15,14 +15,28 @@ class RequestTable(Table): ...@@ -15,14 +15,28 @@ class RequestTable(Table):
args=[A('pk')], args=[A('pk')],
verbose_name=_("ID"), verbose_name=_("ID"),
) )
status = TemplateColumn(
template_name="request/columns/status.html",
verbose_name=_("Status"),
)
user = TemplateColumn(
template_name="request/columns/user.html",
verbose_name=_("User"),
)
type = TemplateColumn(
template_name="request/columns/type.html",
verbose_name=_("Type"),
)
class Meta: class Meta:
model = Request model = Request
template = "django_tables2/with_pagination.html"
attrs = {'class': ('table table-bordered table-striped table-hover'), attrs = {'class': ('table table-bordered table-striped table-hover'),
'id': "request-list-table"} 'id': "request-list-table"}
fields = ("pk", "status", "type", "user", ) fields = ("pk", "status", "type", "user", )
order_by = ("-pk", ) order_by = ("-pk", )
empty_text = _("No more requests.") empty_text = _("No more requests.")
per_page = 10
class LeaseTypeTable(Table): class LeaseTypeTable(Table):
......
<span class="label label-{{ record.get_effect }}" style="font-size: 1.2em;">
<i class="fa fa-{{ record.get_status_icon }}"></i>
{{ record.get_readable_status|upper }}
</span>
<i class="fa fa-{{ record.get_request_icon }}"></i>
{{ record.get_readable_type|title }}
<img src="{{ record.user.profile.get_avatar_url }}" width="20" height="20"/>
<a href="{{ record.user.profile.get_absolute_url }}">
{{ record.user.profile.get_display_name }}
</a>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment