Appraisals implemented
This commit is contained in:
parent
c834976e79
commit
604658d8bf
2
admin.py
2
admin.py
@ -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 = (
|
||||||
|
12
forms.py
12
forms.py
@ -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):
|
||||||
|
23
models.py
23
models.py
@ -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
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 %}
|
||||||
|
8
views.py
8
views.py
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user