Quellcode durchsuchen

Appraisals implemented

master
Dirk Alders vor 4 Jahren
Ursprung
Commit
604658d8bf
6 geänderte Dateien mit 64 neuen und 34 gelöschten Zeilen
  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 Datei anzeigen

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

+ 11
- 1
forms.py Datei anzeigen

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

+ 17
- 6
models.py Datei anzeigen

@@ -136,7 +136,7 @@ class Project(models.Model):
136 136
         return (self.state, self.name)
137 137
 
138 138
     def __str__(self):
139
-        return 'Project: %s' % self.name
139
+        return 'Project #%d: %s' % (self.id, self.name)
140 140
 
141 141
 
142 142
 # TASK Model
@@ -229,10 +229,7 @@ class Task(models.Model):
229 229
         return (100 - self.datafusion_state(), self.state, self.priority, td, self.progress, self.name)
230 230
 
231 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 235
 # COMMENT Model
@@ -266,11 +263,25 @@ class Comment(models.Model):                                    # REQ-19 and REQ
266 263
         else:
267 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 280
     def sort_string(self):
270 281
         return (self.creation_date, self.type, self.comment)
271 282
 
272 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 287
 # SEARCH Model

+ 28
- 20
templates/patt/patt.css Datei anzeigen

@@ -26,7 +26,7 @@
26 26
 }
27 27
 
28 28
 .projectname {
29
-	padding-left: 40px;
29
+  padding-left: 40px;
30 30
 }
31 31
 
32 32
 .projectuserlabel {
@@ -37,11 +37,18 @@
37 37
   padding: 16px;
38 38
 }
39 39
 
40
-.taskcomment {
40
+.taskcomment, .taskappraisal {
41 41
   margin: 16px;
42 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 52
 .taskcomment-date {
46 53
   padding: 16px;
47 54
   font-size: 18px;
@@ -50,7 +57,8 @@
50 57
 }
51 58
 
52 59
 .taskcomment-description {
53
-  padding: 0 50px;
60
+  padding: 16px 50px;
61
+  padding-top: 8px;
54 62
   padding-right: 16px;
55 63
 }
56 64
 
@@ -89,9 +97,9 @@
89 97
 }
90 98
 
91 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 105
 .taskicon:hover {
@@ -100,32 +108,32 @@
100 108
 
101 109
 /* When the screen is less than 700px wide, reduce content to be shown */
102 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 116
 /* When the screen is less than 500px wide, reduce content to be shown */
109 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 123
 /* When the screen is less than 375px wide, reduce content to be shown */
116 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 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 137
 .preview-spacer {
130
-	min-height: 35px;
138
+  min-height: 35px;
131 139
 }

+ 3
- 2
templates/patt/task/comment.html Datei anzeigen

@@ -2,8 +2,9 @@
2 2
 {% load access %}
3 3
 
4 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 7
   <div class="taskcomment-date">{{ comment.creation_date }}{% if comment.user %} ({{ comment.user.username }}){% endif %}:</div>
8 8
   <div class="taskcomment-description">{% render_creole comment.comment comment.attachment_target_path next_anchor %}</div>
9 9
 </div>
10
+{% endif %}

+ 4
- 4
views.py Datei anzeigen

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

Laden…
Abbrechen
Speichern