Commit a4f80f9c authored by cermak's avatar cermak
Browse files

[FIX] Don't create report request if there is already one. Also don't create...

[FIX] Don't create report request if there is already one. Also don't create report requests for T proposals.
parent 455ca602
......@@ -4,6 +4,7 @@ Definition of proposal relatated views.
Means also reports and logs
"""
from datetime import datetime
from app.tables import ProposalTable, ProposalFilter, LogTable, LogSumTable, UsedResourcesTable
from app.models import Proposals, Status, Report, Log, Resource
......@@ -84,8 +85,11 @@ class StatusCreateView(LoginRequiredMixin, CreateView):
response = super().form_valid(form)
# if finished generate report request
if self.object.status == "F":
rr = Report(proposal = self.object.proposal)
rr.save()
# check if there is not report request
if (self.object.proposal.proposaltype in "SP" and self.object.proposal.report_set.count() == 0) or \
(self.object.proposal.proposaltype == "L" and self.object.proposal.report_set.filter(year=datetime.now().year).count() == 0):
rr = Report(proposal = self.object.proposal)
rr.save()
return response
def get_context_data(self, **kwargs):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment