From 604658d8bfd33eccd33b6c5c79f27669016748c8 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Thu, 6 Feb 2020 15:23:58 +0100 Subject: [PATCH] Appraisals implemented --- admin.py | 2 +- forms.py | 12 +++++++- models.py | 23 +++++++++++---- templates/patt/patt.css | 48 +++++++++++++++++++------------- templates/patt/task/comment.html | 5 ++-- views.py | 8 +++--- 6 files changed, 64 insertions(+), 34 deletions(-) diff --git a/admin.py b/admin.py index ce655ac..fb7b755 100644 --- a/admin.py +++ b/admin.py @@ -26,7 +26,7 @@ class TaskAdmin(SimpleHistoryAdmin): class CommentAdmin(SimpleHistoryAdmin): - list_display = ('task', 'user', 'comment', ) + list_display = ('task', 'user', 'type', 'comment', ) history_list_display = ('comment', 'type', ) search_fields = ('comment', ) list_filter = ( diff --git a/forms.py b/forms.py index 3f1a710..492c140 100644 --- a/forms.py +++ b/forms.py @@ -103,7 +103,17 @@ class ProjectForm(forms.ModelForm): class CommentForm(forms.ModelForm): class Meta: model = Comment - fields = ['comment'] + fields = ['type', 'comment'] + + def __init__(self, *args, **kwargs): + try: + acc = kwargs.pop('acc') + except KeyError: + disable_type = True + else: + disable_type = not acc.modify_comment + super(forms.ModelForm, self).__init__(*args, **kwargs) + self.fields['type'].disabled = disable_type class TaskCommentForm(forms.ModelForm): diff --git a/models.py b/models.py index 7441d7e..a316650 100644 --- a/models.py +++ b/models.py @@ -136,7 +136,7 @@ class Project(models.Model): return (self.state, self.name) def __str__(self): - return 'Project: %s' % self.name + return 'Project #%d: %s' % (self.id, self.name) # TASK Model @@ -229,10 +229,7 @@ class Task(models.Model): return (100 - self.datafusion_state(), self.state, self.priority, td, self.progress, self.name) def __str__(self): - if self.project: - return 'Task: %s - %s' % (self.project.name, self.name) - else: - return 'Task: %s' % (self.name) + return 'Task #%d: %s' % (self.id, self.name) # COMMENT Model @@ -266,11 +263,25 @@ class Comment(models.Model): # REQ-19 and REQ else: return 'patt/comment/new' + @property + def style(self): + return { + COMMENTTYPE_APPRAISAL: 'taskappraisal', + }.get(self.type, 'taskcomment') + + @property + def is_comment(self): + return self.type == COMMENTTYPE_COMMENT + + @property + def is_appraisal(self): + return self.type == COMMENTTYPE_APPRAISAL + def sort_string(self): return (self.creation_date, self.type, self.comment) def __str__(self): - return 'Comment: %s - %d' % (self.task.name, self.id) + return 'Comment #%d: %s' % (self.id, self.task.name) # SEARCH Model diff --git a/templates/patt/patt.css b/templates/patt/patt.css index 990ddba..4524275 100644 --- a/templates/patt/patt.css +++ b/templates/patt/patt.css @@ -26,7 +26,7 @@ } .projectname { - padding-left: 40px; + padding-left: 40px; } .projectuserlabel { @@ -37,11 +37,18 @@ padding: 16px; } -.taskcomment { +.taskcomment, .taskappraisal { margin: 16px; border-left: 6px solid #323232; } +.taskappraisal { + border-left: 6px solid #005d7a; + color: #005d7a; + background-color: #eeeeee; +} + + .taskcomment-date { padding: 16px; font-size: 18px; @@ -50,7 +57,8 @@ } .taskcomment-description { - padding: 0 50px; + padding: 16px 50px; + padding-top: 8px; padding-right: 16px; } @@ -89,9 +97,9 @@ } .projecticon { - position: absolute; - top: 0; - left: 0; + position: absolute; + top: 0; + left: 0; } .taskicon:hover { @@ -100,32 +108,32 @@ /* When the screen is less than 700px wide, reduce content to be shown */ @media screen and (max-width: 700px) { - .prio_icons_hide { - display: none - } + .prio_icons_hide { + display: none + } } /* When the screen is less than 500px wide, reduce content to be shown */ @media screen and (max-width: 500px) { - .target_date_hide { - display: none - } + .target_date_hide { + display: none + } } /* When the screen is less than 375px wide, reduce content to be shown */ @media screen and (max-width: 375px) { - .state_icons_hide { - display: none - } + .state_icons_hide { + display: none + } } .preview { - background-image: url("{% static 'patt/draft.png' %}"); - padding: 40px; - padding-top: 75px; - min-height: 300px; + background-image: url("{% static 'patt/draft.png' %}"); + padding: 40px; + padding-top: 75px; + min-height: 300px; } .preview-spacer { - min-height: 35px; + min-height: 35px; } diff --git a/templates/patt/task/comment.html b/templates/patt/task/comment.html index a741978..d449238 100644 --- a/templates/patt/task/comment.html +++ b/templates/patt/task/comment.html @@ -2,8 +2,9 @@ {% load access %} {% may_modify_comment comment as user_may_modify_comment %} - -
+{% if comment.is_comment or comment.is_appraisal and user_may_modify_comment %} +
{{ comment.creation_date }}{% if comment.user %} ({{ comment.user.username }}){% endif %}:
{% render_creole comment.comment comment.attachment_target_path next_anchor %}
+{% endif %} diff --git a/views.py b/views.py index c89d74b..231f69e 100644 --- a/views.py +++ b/views.py @@ -506,7 +506,7 @@ def patt_commentnew(request, task_id): acc = acc_task(task, request.user) if acc.add_comments: if not request.POST: - form = CommentForm(instance=Comment()) + form = CommentForm(instance=Comment(), acc=acc) context_adaption( context, # the base context request, # the request object to be used in context_adaption @@ -521,7 +521,7 @@ def patt_commentnew(request, task_id): else: comment = Comment(task_id=task_id, user=request.user) # - form = CommentForm(request.POST, instance=comment) + form = CommentForm(request.POST, instance=comment, acc=acc) context_adaption( context, # the base context request, # the request object to be used in context_adaption @@ -554,7 +554,7 @@ def patt_commentedit(request, task_id, comment_id): acc = acc_task(comment.task, request.user) if acc.modify_comment: if not request.POST: - form = CommentForm(instance=comment) + form = CommentForm(instance=comment, acc=acc) context_adaption( context, # the base context request, # the request object to be used in context_adaption @@ -567,7 +567,7 @@ def patt_commentedit(request, task_id, comment_id): ) return render(request, 'patt/raw_single_form.html', context=context) else: - form = CommentForm(request.POST, instance=comment) + form = CommentForm(request.POST, instance=comment, acc=acc) context_adaption( context, # the base context request, # the request object to be used in context_adaption