Conversation
0ad3c33 to
c45eb4d
Compare
d572781 to
9abc042
Compare
c45eb4d to
f0292c2
Compare
9abc042 to
3448416
Compare
| $('#dialog').dialog('open'); | ||
| }); | ||
| }); | ||
| </script> |
There was a problem hiding this comment.
Please move this javascript function to .js file
| </tr> | ||
| {% for date, reports in reports_dict.items %} | ||
| <tr> | ||
| <td style="width:128px" rowspan={{ reports|length }}> |
There was a problem hiding this comment.
Please move all inline styling to .css file
|
|
||
| <h1>{{ UI_text.PAGE_TITLE.value }}{{ report.project }} ({{ report.date }})</h1> | ||
| </br> | ||
| <div class="modal-dialog" style="margin-bottom:0"> |
There was a problem hiding this comment.
If you have any styling please move it to .css file
| def test_queryset_as_dict_should_return_dictionary_where_keys_are_dates_and_values_are_lists_of_reports(self): | ||
| queryset = Report.objects.all() | ||
| dictionary = query_as_dict(queryset) | ||
| self.assertEqual(len(dictionary.items()), 2) |
There was a problem hiding this comment.
You don't have to convert it into list. len() function works also with dicts :)
| self.assertTrue(isinstance(list(dictionary.keys())[1], datetime.date)) | ||
| self.assertTrue(isinstance(list(dictionary.values())[0][0], Report)) | ||
| self.assertTrue(isinstance(list(dictionary.values())[0][1], Report)) | ||
| self.assertTrue(isinstance(list(dictionary.values())[1][0], Report)) |
There was a problem hiding this comment.
You don't have to use self.assertTrue to all of them. It is enough to have only self.isinstance(). Also you don't have to use list converting as well, as I wrote above.
There was a problem hiding this comment.
List conversion was required for indexing, because neither dictionary.values() nor dictionary.keys() return an indexable type.
| key = record.date | ||
| dictionary.setdefault(key, []) | ||
| dictionary[key].append(record) | ||
| return dictionary |
There was a problem hiding this comment.
I saw this function in @MartynaAnnaGottschling PR. It should be in utils and be reusable for more than one app.
There was a problem hiding this comment.
I can tell you right now, that it will change it's functionality later on to be more specific. It's used to return specific set of data, designed for rendering lists of reports in requested format. Granted such method might be potentially useful in other places, but in reality we store all report related views in employees app (because that's were report model and serializer are stored in the first place).
And @MartynaAnnaGottschling won't be using it anymore, because it was useless for her anyway. It also actually performed different action than mine.
Do you still want me to move it to utils? Like I said, it's a specific tool meant to be used with employees app only.
| 'reports_dict': reports_dict, | ||
| 'UI_text': ReportListStrings, | ||
| }, status=201) | ||
| # QUESTION: Should I use some sort of database verification prior to returning Response with status 201? |
There was a problem hiding this comment.
I think that we will need to think about it how to do database verification. If any error occurs will save() method raise exception? Please investigate it.
There was a problem hiding this comment.
So after my thorough investigation, it turns out that Django in fact throws an AssertionError if serializer.save() is called without serializer.is_valid() preceding it. Thus it forces you to perform validation check on serializer before saving it's data in database.
So I sabotaged the serializer to have it pass incomplete data to model. In such case an IntegrityError is thrown if model receives bad data.
| serializer = ReportSerializer( | ||
| report, data=request.data, | ||
| context={'request': request} | ||
| ) |
There was a problem hiding this comment.
Please change it into:
serializer = ReportSerializer(
report,
data=request.data,
context={'request': request}
)| <td style="padding:0 15px 0 15px;"><a href="{% url 'custom-projects-list' %}">{% trans 'Projects list' %}</a></td> | ||
| {% endif %} | ||
| <td style="padding:0 15px 0 15px;"><a href="{% url 'custom-report-list' %}">{% trans 'Reports' %}</a></td> | ||
| <td style="padding:0 15px 0 15px;"><a href="{% url 'logout' %}">{% trans 'Logout' %}</a></td> |
There was a problem hiding this comment.
Please move style to .css file
| @@ -0,0 +1,3 @@ | |||
| def notCallable(cls): | |||
| cls.do_not_call_in_templates = True | |||
| return cls | |||
There was a problem hiding this comment.
Is this decorator necessary?
There was a problem hiding this comment.
Yes, it is absolutely necessary in order to make enums accessible in templates. Otherwise no value is displayed after render.
I forgot what was exactly the issue, but it has something to do with calls in Django.
b172f97 to
d6924dd
Compare
d6924dd to
18687db
Compare
68c67fd to
a38ed81
Compare
18687db to
d5f74fb
Compare
|
@maciejSamerdak After some digging I see this is the starting pull request for the three following up :) But why it is being compared to |
0a10086 to
9e1a6e3
Compare
79e6049 to
de9086a
Compare
kbeker
left a comment
There was a problem hiding this comment.
Just one thing to clarify and ready to merge.
After using this decorator, enum values can be easily accessed from templates.
Also pushes existing DRF views to '*/api/' path
de9086a to
b3ac00d
Compare


Resolves #39, resolves #48