Commit 28cad8b1 by Kálmán Viktor

request: add closed by to model

parent b4bf105c
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('request', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='request',
name='closed_by',
field=models.ForeignKey(related_name='closed_by', to=settings.AUTH_USER_MODEL, null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='request',
name='user',
field=models.ForeignKey(related_name='user', to=settings.AUTH_USER_MODEL),
preserve_default=True,
),
]
......@@ -42,7 +42,8 @@ class Request(TimeStampedModel):
)
status = CharField(choices=STATUSES, default=STATUSES.UNSEEN,
max_length=10)
user = ForeignKey(User, verbose_name=_('user'))
user = ForeignKey(User, related_name="user")
closed_by = ForeignKey(User, related_name="closed_by", null=True)
TYPES = Choices(
('resource', _('resource request')),
('lease', _("lease request")),
......@@ -90,10 +91,12 @@ class Request(TimeStampedModel):
def accept(self, user):
self.action.accept(user)
self.status = "ACCEPTED"
self.closed_by = user
self.save()
def decline(self):
def decline(self, user):
self.status = "DECLINED"
self.closed_by = user
self.save()
......
......@@ -3,7 +3,7 @@ from django.utils.translation import ugettext_lazy as _
from django_tables2 import Table, A
from django_tables2.columns import (
TemplateColumn, LinkColumn
Column, TemplateColumn, LinkColumn
)
from request.models import Request, LeaseType, TemplateAccessType
......@@ -45,6 +45,7 @@ class LeaseTypeTable(Table):
args=[A('pk')],
verbose_name=_("ID"),
)
lease = Column(verbose_name=_("Lease"))
class Meta:
model = LeaseType
......
<i class="fa fa-{{ record.get_request_icon }}"></i>
{{ record.get_readable_type|title }}
{{ record.get_readable_type|capfirst }}
......@@ -2,6 +2,7 @@
{% load staticfiles %}
{% load i18n %}
{% load render_table from django_tables2 %}
{% load arrowfilter %}
{% block title-page %}{% trans "Request" %}{% endblock %}
......@@ -26,7 +27,7 @@
</div>
<p>
<img src="{{ object.user.profile.get_avatar_url }}" width="50" height="50"/>
<a href="{{ object.user.profile.get_absolute_url }} ">
<a href="{{ object.user.profile.get_absolute_url }}">
{{ object.user.profile.get_display_name }}
</a>
</p>
......@@ -113,8 +114,8 @@
</div>
{% else %}
<div class="text-right">
{% blocktrans with close_date=object.modified %}
Closed at {{ close_date }}
{% blocktrans with closed=object.modified|arrowfilter:LANGUAGE_CODE user=object.closed_by.profile.get_display_name %}
Closed {{ closed }} by <a href="{{ user.profile.get_absolute_url }}">{{ user }}</a>
{% endblocktrans %}
</div>
{% endif %}
......
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