Conversation
62dbd03 to
e4c4490
Compare
8fc548b to
75c93ad
Compare
employees/views.py
Outdated
|
|
||
|
|
||
| @method_decorator(login_required, name="dispatch") | ||
| class ProjectReportList(ListView): |
There was a problem hiding this comment.
After looking at this finally, I think you were right in the version - it should be DetailView, with model Project, and reports should taken in template by some Project model method to apply ordering. This method could look like this:
def get_reports_ordered(self):
return self.report_set.order_by("-date", "project__name")
Please only remember to have it already fetched using .select_related in get_queryset() method.
employees/views.py
Outdated
| def get_context_data(self, **kwargs: Any) -> dict: | ||
| context = super().get_context_data(**kwargs) | ||
| context["UI_text"] = ProjectReportListStrings | ||
| context["project_name"] = get_object_or_404(Project, pk=self.kwargs["pk"]) |
There was a problem hiding this comment.
When https://github.com/Code-Poets/sheetstorm/pull/133/files#r283077801 is applied you don't need this, because you have project as object.
employees/views.py
Outdated
| return context | ||
|
|
||
| def get_success_url(self) -> str: | ||
| return reverse("project-report-list", kwargs={"pk": self.object.project.id}) |
There was a problem hiding this comment.
Please remember to update this too.
| <td class="project-reports-edit-button-header Invisible"></td> | ||
| </tr> | ||
| <tbody> | ||
| {% regroup object_list by date as reports_by_date %} |
There was a problem hiding this comment.
Here you would use the get_reports_ordered method.
|
@kbeker Looks good but please change to DetailView with Project as model, it looks more natural in this case. |
75c93ad to
cd5cc4f
Compare
Introduces list view for all reports from selected project.
Related #130
Do not delete this branch until #135 and #134 are merged