Browse Source

Appraisals implemented

master
Dirk Alders 4 years ago
parent
commit
604658d8bf
6 changed files with 64 additions and 34 deletions
  1. 1
    1
      admin.py
  2. 11
    1
      forms.py
  3. 17
    6
      models.py
  4. 28
    20
      templates/patt/patt.css
  5. 3
    2
      templates/patt/task/comment.html
  6. 4
    4
      views.py

+ 1
- 1
admin.py View File

26
 
26
 
27
 
27
 
28
 class CommentAdmin(SimpleHistoryAdmin):
28
 class CommentAdmin(SimpleHistoryAdmin):
29
-    list_display = ('task', 'user', 'comment', )
29
+    list_display = ('task', 'user', 'type', 'comment', )
30
     history_list_display = ('comment', 'type', )
30
     history_list_display = ('comment', 'type', )
31
     search_fields = ('comment', )
31
     search_fields = ('comment', )
32
     list_filter = (
32
     list_filter = (

+ 11
- 1
forms.py View File

103
 class CommentForm(forms.ModelForm):
103
 class CommentForm(forms.ModelForm):
104
     class Meta:
104
     class Meta:
105
         model = Comment
105
         model = Comment
106
-        fields = ['comment']
106
+        fields = ['type', 'comment']
107
+
108
+    def __init__(self, *args, **kwargs):
109
+        try:
110
+            acc = kwargs.pop('acc')
111
+        except KeyError:
112
+            disable_type = True
113
+        else:
114
+            disable_type = not acc.modify_comment
115
+        super(forms.ModelForm, self).__init__(*args, **kwargs)
116
+        self.fields['type'].disabled = disable_type
107
 
117
 
108
 
118
 
109
 class TaskCommentForm(forms.ModelForm):
119
 class TaskCommentForm(forms.ModelForm):

+ 17
- 6
models.py View File

136
         return (self.state, self.name)
136
         return (self.state, self.name)
137
 
137
 
138
     def __str__(self):
138
     def __str__(self):
139
-        return 'Project: %s' % self.name
139
+        return 'Project #%d: %s' % (self.id, self.name)
140
 
140
 
141
 
141
 
142
 # TASK Model
142
 # TASK Model
229
         return (100 - self.datafusion_state(), self.state, self.priority, td, self.progress, self.name)
229
         return (100 - self.datafusion_state(), self.state, self.priority, td, self.progress, self.name)
230
 
230
 
231
     def __str__(self):
231
     def __str__(self):
232
-        if self.project:
233
-            return 'Task: %s - %s' % (self.project.name, self.name)
234
-        else:
235
-            return 'Task: %s' % (self.name)
232
+        return 'Task #%d: %s' % (self.id, self.name)
236
 
233
 
237
 
234
 
238
 # COMMENT Model
235
 # COMMENT Model
266
         else:
263
         else:
267
             return 'patt/comment/new'
264
             return 'patt/comment/new'
268
 
265
 
266
+    @property
267
+    def style(self):
268
+        return {
269
+            COMMENTTYPE_APPRAISAL: 'taskappraisal',
270
+        }.get(self.type, 'taskcomment')
271
+
272
+    @property
273
+    def is_comment(self):
274
+        return self.type == COMMENTTYPE_COMMENT
275
+
276
+    @property
277
+    def is_appraisal(self):
278
+        return self.type == COMMENTTYPE_APPRAISAL
279
+
269
     def sort_string(self):
280
     def sort_string(self):
270
         return (self.creation_date, self.type, self.comment)
281
         return (self.creation_date, self.type, self.comment)
271
 
282
 
272
     def __str__(self):
283
     def __str__(self):
273
-        return 'Comment: %s - %d' % (self.task.name, self.id)
284
+        return 'Comment #%d: %s' % (self.id, self.task.name)
274
 
285
 
275
 
286
 
276
 # SEARCH Model
287
 # SEARCH Model

+ 28
- 20
templates/patt/patt.css View File

26
 }
26
 }
27
 
27
 
28
 .projectname {
28
 .projectname {
29
-	padding-left: 40px;
29
+  padding-left: 40px;
30
 }
30
 }
31
 
31
 
32
 .projectuserlabel {
32
 .projectuserlabel {
37
   padding: 16px;
37
   padding: 16px;
38
 }
38
 }
39
 
39
 
40
-.taskcomment {
40
+.taskcomment, .taskappraisal {
41
   margin: 16px;
41
   margin: 16px;
42
   border-left: 6px solid #323232;
42
   border-left: 6px solid #323232;
43
 }
43
 }
44
 
44
 
45
+.taskappraisal {
46
+  border-left: 6px solid #005d7a;
47
+  color: #005d7a;
48
+  background-color: #eeeeee;
49
+}
50
+
51
+
45
 .taskcomment-date {
52
 .taskcomment-date {
46
   padding: 16px;
53
   padding: 16px;
47
   font-size: 18px;
54
   font-size: 18px;
50
 }
57
 }
51
 
58
 
52
 .taskcomment-description {
59
 .taskcomment-description {
53
-  padding: 0 50px;
60
+  padding: 16px 50px;
61
+  padding-top: 8px;
54
   padding-right: 16px;
62
   padding-right: 16px;
55
 }
63
 }
56
 
64
 
89
 }
97
 }
90
 
98
 
91
 .projecticon {
99
 .projecticon {
92
-	position: absolute;
93
-	top: 0;
94
-	left: 0;
100
+  position: absolute;
101
+  top: 0;
102
+  left: 0;
95
 }
103
 }
96
 
104
 
97
 .taskicon:hover {
105
 .taskicon:hover {
100
 
108
 
101
 /* When the screen is less than 700px wide, reduce content to be shown */
109
 /* When the screen is less than 700px wide, reduce content to be shown */
102
 @media screen and (max-width: 700px) {
110
 @media screen and (max-width: 700px) {
103
-    .prio_icons_hide {
104
-        display: none
105
-    }
111
+  .prio_icons_hide {
112
+    display: none
113
+  }
106
 }
114
 }
107
 
115
 
108
 /* When the screen is less than 500px wide, reduce content to be shown */
116
 /* When the screen is less than 500px wide, reduce content to be shown */
109
 @media screen and (max-width: 500px) {
117
 @media screen and (max-width: 500px) {
110
-    .target_date_hide {
111
-        display: none
112
-    }
118
+  .target_date_hide {
119
+    display: none
120
+  }
113
 }
121
 }
114
 
122
 
115
 /* When the screen is less than 375px wide, reduce content to be shown */
123
 /* When the screen is less than 375px wide, reduce content to be shown */
116
 @media screen and (max-width: 375px) {
124
 @media screen and (max-width: 375px) {
117
-    .state_icons_hide {
118
-        display: none
119
-    }
125
+  .state_icons_hide {
126
+    display: none
127
+  }
120
 }
128
 }
121
 
129
 
122
 .preview {
130
 .preview {
123
-	background-image: url("{% static 'patt/draft.png' %}");
124
-	padding: 40px;
125
-	padding-top: 75px;
126
-	min-height: 300px;
131
+  background-image: url("{% static 'patt/draft.png' %}");
132
+  padding: 40px;
133
+  padding-top: 75px;
134
+  min-height: 300px;
127
 }
135
 }
128
 
136
 
129
 .preview-spacer {
137
 .preview-spacer {
130
-	min-height: 35px;
138
+  min-height: 35px;
131
 }
139
 }

+ 3
- 2
templates/patt/task/comment.html View File

2
 {% load access %}
2
 {% load access %}
3
 
3
 
4
 {% may_modify_comment comment as user_may_modify_comment %}
4
 {% may_modify_comment comment as user_may_modify_comment %}
5
-
6
-<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 %}>
5
+{% if comment.is_comment or comment.is_appraisal and user_may_modify_comment %}
6
+<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 %}>
7
   <div class="taskcomment-date">{{ comment.creation_date }}{% if comment.user %} ({{ comment.user.username }}){% endif %}:</div>
7
   <div class="taskcomment-date">{{ comment.creation_date }}{% if comment.user %} ({{ comment.user.username }}){% endif %}:</div>
8
   <div class="taskcomment-description">{% render_creole comment.comment comment.attachment_target_path next_anchor %}</div>
8
   <div class="taskcomment-description">{% render_creole comment.comment comment.attachment_target_path next_anchor %}</div>
9
 </div>
9
 </div>
10
+{% endif %}

+ 4
- 4
views.py View File

506
         acc = acc_task(task, request.user)
506
         acc = acc_task(task, request.user)
507
         if acc.add_comments:
507
         if acc.add_comments:
508
             if not request.POST:
508
             if not request.POST:
509
-                form = CommentForm(instance=Comment())
509
+                form = CommentForm(instance=Comment(), acc=acc)
510
                 context_adaption(
510
                 context_adaption(
511
                     context,                                            # the base context
511
                     context,                                            # the base context
512
                     request,                                            # the request object to be used in context_adaption
512
                     request,                                            # the request object to be used in context_adaption
521
             else:
521
             else:
522
                 comment = Comment(task_id=task_id, user=request.user)
522
                 comment = Comment(task_id=task_id, user=request.user)
523
                 #
523
                 #
524
-                form = CommentForm(request.POST, instance=comment)
524
+                form = CommentForm(request.POST, instance=comment, acc=acc)
525
                 context_adaption(
525
                 context_adaption(
526
                     context,                                            # the base context
526
                     context,                                            # the base context
527
                     request,                                            # the request object to be used in context_adaption
527
                     request,                                            # the request object to be used in context_adaption
554
     acc = acc_task(comment.task, request.user)
554
     acc = acc_task(comment.task, request.user)
555
     if acc.modify_comment:
555
     if acc.modify_comment:
556
         if not request.POST:
556
         if not request.POST:
557
-            form = CommentForm(instance=comment)
557
+            form = CommentForm(instance=comment, acc=acc)
558
             context_adaption(
558
             context_adaption(
559
                 context,                                            # the base context
559
                 context,                                            # the base context
560
                 request,                                            # the request object to be used in context_adaption
560
                 request,                                            # the request object to be used in context_adaption
567
             )
567
             )
568
             return render(request, 'patt/raw_single_form.html', context=context)
568
             return render(request, 'patt/raw_single_form.html', context=context)
569
         else:
569
         else:
570
-            form = CommentForm(request.POST, instance=comment)
570
+            form = CommentForm(request.POST, instance=comment, acc=acc)
571
             context_adaption(
571
             context_adaption(
572
                 context,                                        # the base context
572
                 context,                                        # the base context
573
                 request,                                        # the request object to be used in context_adaption
573
                 request,                                        # the request object to be used in context_adaption

Loading…
Cancel
Save