Conversation
1b8b92a to
4bf6d9e
Compare
5c8805c to
4c22d16
Compare
kbeker
left a comment
There was a problem hiding this comment.
I'm tired of reviewing all this PR's but this is the last one :D Please apply my changes
| def __init__(self, queryset, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| assert isinstance(queryset, QuerySet) | ||
| # assert isinstance(queryset.model, Project) No exception message supplied |
| project.members.add(self.request.user) | ||
| project.full_clean() | ||
| project.save() | ||
| project.refresh_from_db() |
There was a problem hiding this comment.
Is it necessary here? I think it should work without refreshing database.
| reports_serializer = ReportSerializer(data=request.data, context={'request': request}) | ||
| reports_dict = query_as_dict(self.get_queryset()) | ||
|
|
||
| if 'join' in request.POST: |
There was a problem hiding this comment.
This could be changed to some kind of Enum and reused in place where it is assigned to request. Thanks to this will not stop working if it will be changed in another place
There was a problem hiding this comment.
You mean the 'join' string? It's an id from HTML template, so I'd say it's name is rather irrelevant, but I could supply some sort of constant for it. The question is whether it's worth the extra effort?
There was a problem hiding this comment.
Yea, you're right. It won't be necessary :)
| 'project_form': self.project_form, | ||
| }) | ||
|
|
||
| if not reports_serializer.is_valid(): |
There was a problem hiding this comment.
Also please change it into elif
There was a problem hiding this comment.
What are the benefits of it?
| 'UI_text': ReportListStrings, | ||
| 'project_form': self.project_form, | ||
| }, 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.
This should be deleted in previous PR. What save() method returns if something goes wrong should be investigated.
| $('#dialog').dialog('open'); | ||
| }); | ||
| }); | ||
| </script> |
There was a problem hiding this comment.
Move this function to .js file
| queryset_length = 10 | ||
| for i in range(queryset_length): | ||
| self.project = Project( | ||
| name="Test Project %d" % i, |
There was a problem hiding this comment.
Please change it into f-string
802317d to
620bd5b
Compare
ba63f8b to
b899baa
Compare
942cd4b to
3386a7d
Compare
2823264 to
328f7b0
Compare
|
@maciejSamerdak It would be good to create an issue for what you are adding with this pull request, or link to an existing one. |
d32b90a to
c0e9652
Compare
3386a7d to
78535dd
Compare
93f13c4 to
805e3a5
Compare
78535dd to
693846b
Compare
805e3a5 to
d52c409
Compare
693846b to
1af60a5
Compare
f2ef2ef to
2470564
Compare
2470564 to
239157f
Compare
kbeker
left a comment
There was a problem hiding this comment.
Generally OK. Please squash fixups and apply one thing which I mentioned in comment
| response = ReportDetail.as_view()(request, pk=self.report.pk) | ||
| self.report.refresh_from_db() | ||
| self.assertEqual(response.status_code, 200) | ||
| self.assertIsNotNone(response.data['errors']) |
There was a problem hiding this comment.
Please change this assert that you check exactly what error is in this dict
There was a problem hiding this comment.
In order to get to the ErrorDetail object, I have to do this:
response.data['errors']['project'][0]
Then I can either get to the code
response.data['errors']['project'][0].code = 'does_not_exist'
or to the (very specific) message
str(response.data['errors']['project'][0]) = 'Object with name=Other Project does not exist.'
Which one should I use? Or should just narrow it down to checking if field specific errors exist? self.assertIsNotNone(response.data['errors']['project'])
There was a problem hiding this comment.
@maciejSamerdak I would prefer to check response.data['errors']['project'][0].code = 'does_not_exist' but I know that to change it everywhere is very big effort, so please just apply this to this PR.
| reports_serializer = ReportSerializer(data=request.data, context={'request': request}) | ||
| reports_dict = query_as_dict(self.get_queryset()) | ||
|
|
||
| if 'join' in request.POST: |
There was a problem hiding this comment.
Yea, you're right. It won't be necessary :)
ba8ccc0 to
083c20c
Compare
Adds form with singular `ChoiceField` which is supposed to contain a list of projects the user can join to.
Due to increased complexity of its' functionality, the class' structure has been heavily modified, introducing helper methods and additional fields. Most important of all, an `initial` method, which contains actions to be performed before each HTTP call, has been overridden to include initiation of aforementioned fields.
Added javascript and HTML code for pop-up functionality
Limits projects displayed in project field in report detail view to only those which author is a member of.
Adds tests for project join form and extends tests in custom views, regarding applied changes to code.
083c20c to
dbc9487
Compare
Resolves #42
Resolves #105