Appraisals implemented

This commit is contained in:
Dirk Alders 2020-02-06 15:23:58 +01:00
parent c834976e79
commit 604658d8bf
6 changed files with 64 additions and 34 deletions

View File

@ -26,7 +26,7 @@ class TaskAdmin(SimpleHistoryAdmin):
class CommentAdmin(SimpleHistoryAdmin): class CommentAdmin(SimpleHistoryAdmin):
list_display = ('task', 'user', 'comment', ) list_display = ('task', 'user', 'type', 'comment', )
history_list_display = ('comment', 'type', ) history_list_display = ('comment', 'type', )
search_fields = ('comment', ) search_fields = ('comment', )
list_filter = ( list_filter = (

View File

@ -103,7 +103,17 @@ class ProjectForm(forms.ModelForm):
class CommentForm(forms.ModelForm): class CommentForm(forms.ModelForm):
class Meta: class Meta:
model = Comment 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): class TaskCommentForm(forms.ModelForm):

View File

@ -136,7 +136,7 @@ class Project(models.Model):
return (self.state, self.name) return (self.state, self.name)
def __str__(self): def __str__(self):
return 'Project: %s' % self.name return 'Project #%d: %s' % (self.id, self.name)
# TASK Model # TASK Model
@ -229,10 +229,7 @@ class Task(models.Model):
return (100 - self.datafusion_state(), self.state, self.priority, td, self.progress, self.name) return (100 - self.datafusion_state(), self.state, self.priority, td, self.progress, self.name)
def __str__(self): def __str__(self):
if self.project: return 'Task #%d: %s' % (self.id, self.name)
return 'Task: %s - %s' % (self.project.name, self.name)
else:
return 'Task: %s' % (self.name)
# COMMENT Model # COMMENT Model
@ -266,11 +263,25 @@ class Comment(models.Model): # REQ-19 and REQ
else: else:
return 'patt/comment/new' 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): def sort_string(self):
return (self.creation_date, self.type, self.comment) return (self.creation_date, self.type, self.comment)
def __str__(self): def __str__(self):
return 'Comment: %s - %d' % (self.task.name, self.id) return 'Comment #%d: %s' % (self.id, self.task.name)
# SEARCH Model # SEARCH Model

View File

@ -26,7 +26,7 @@
} }
.projectname { .projectname {
padding-left: 40px; padding-left: 40px;
} }
.projectuserlabel { .projectuserlabel {
@ -37,11 +37,18 @@
padding: 16px; padding: 16px;
} }
.taskcomment { .taskcomment, .taskappraisal {
margin: 16px; margin: 16px;
border-left: 6px solid #323232; border-left: 6px solid #323232;
} }
.taskappraisal {
border-left: 6px solid #005d7a;
color: #005d7a;
background-color: #eeeeee;
}
.taskcomment-date { .taskcomment-date {
padding: 16px; padding: 16px;
font-size: 18px; font-size: 18px;
@ -50,7 +57,8 @@
} }
.taskcomment-description { .taskcomment-description {
padding: 0 50px; padding: 16px 50px;
padding-top: 8px;
padding-right: 16px; padding-right: 16px;
} }
@ -89,9 +97,9 @@
} }
.projecticon { .projecticon {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
} }
.taskicon:hover { .taskicon:hover {
@ -100,32 +108,32 @@
/* When the screen is less than 700px wide, reduce content to be shown */ /* When the screen is less than 700px wide, reduce content to be shown */
@media screen and (max-width: 700px) { @media screen and (max-width: 700px) {
.prio_icons_hide { .prio_icons_hide {
display: none display: none
} }
} }
/* When the screen is less than 500px wide, reduce content to be shown */ /* When the screen is less than 500px wide, reduce content to be shown */
@media screen and (max-width: 500px) { @media screen and (max-width: 500px) {
.target_date_hide { .target_date_hide {
display: none display: none
} }
} }
/* When the screen is less than 375px wide, reduce content to be shown */ /* When the screen is less than 375px wide, reduce content to be shown */
@media screen and (max-width: 375px) { @media screen and (max-width: 375px) {
.state_icons_hide { .state_icons_hide {
display: none display: none
} }
} }
.preview { .preview {
background-image: url("{% static 'patt/draft.png' %}"); background-image: url("{% static 'patt/draft.png' %}");
padding: 40px; padding: 40px;
padding-top: 75px; padding-top: 75px;
min-height: 300px; min-height: 300px;
} }
.preview-spacer { .preview-spacer {
min-height: 35px; min-height: 35px;
} }

View File

@ -2,8 +2,9 @@
{% load access %} {% load access %}
{% may_modify_comment comment as user_may_modify_comment %} {% may_modify_comment comment as user_may_modify_comment %}
{% if comment.is_comment or comment.is_appraisal and user_may_modify_comment %}
<div class="taskcomment"{% if printview != True and user_may_modify_comment %} onclick="location.href='{% url 'patt-commentedit' task_id=task.id comment_id=comment.id %}{{"?next="|add:request.path }}';" style="cursor:pointer;"{% endif %}> <div class="{{ comment.style }}"{% if printview != True and user_may_modify_comment %} onclick="location.href='{% url 'patt-commentedit' task_id=task.id comment_id=comment.id %}{{"?next="|add:request.path }}';" style="cursor:pointer;"{% endif %}>
<div class="taskcomment-date">{{ comment.creation_date }}{% if comment.user %} ({{ comment.user.username }}){% endif %}:</div> <div class="taskcomment-date">{{ comment.creation_date }}{% if comment.user %} ({{ comment.user.username }}){% endif %}:</div>
<div class="taskcomment-description">{% render_creole comment.comment comment.attachment_target_path next_anchor %}</div> <div class="taskcomment-description">{% render_creole comment.comment comment.attachment_target_path next_anchor %}</div>
</div> </div>
{% endif %}

View File

@ -506,7 +506,7 @@ def patt_commentnew(request, task_id):
acc = acc_task(task, request.user) acc = acc_task(task, request.user)
if acc.add_comments: if acc.add_comments:
if not request.POST: if not request.POST:
form = CommentForm(instance=Comment()) form = CommentForm(instance=Comment(), acc=acc)
context_adaption( context_adaption(
context, # the base context context, # the base context
request, # the request object to be used in context_adaption request, # the request object to be used in context_adaption
@ -521,7 +521,7 @@ def patt_commentnew(request, task_id):
else: else:
comment = Comment(task_id=task_id, user=request.user) 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_adaption(
context, # the base context context, # the base context
request, # the request object to be used in context_adaption 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) acc = acc_task(comment.task, request.user)
if acc.modify_comment: if acc.modify_comment:
if not request.POST: if not request.POST:
form = CommentForm(instance=comment) form = CommentForm(instance=comment, acc=acc)
context_adaption( context_adaption(
context, # the base context context, # the base context
request, # the request object to be used in context_adaption 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) return render(request, 'patt/raw_single_form.html', context=context)
else: else:
form = CommentForm(request.POST, instance=comment) form = CommentForm(request.POST, instance=comment, acc=acc)
context_adaption( context_adaption(
context, # the base context context, # the base context
request, # the request object to be used in context_adaption request, # the request object to be used in context_adaption