#149 Send on changes
* changes trigger for sending data to EGON: on each new payment, edited payment or deleted payment action, the data will be sent to EGON instead only once on "recording"
This commit is contained in:
parent
5a8765f638
commit
eb975cd3c5
@ -128,6 +128,7 @@ class EditPaymentModalForm(NewPaymentForm):
|
||||
payment.comment = self.cleaned_data.get("comment", None)
|
||||
payment.save()
|
||||
self.instance.mark_as_edited(self.user, self.request, edit_comment=PAYMENT_EDITED)
|
||||
self.instance.send_data_to_egon()
|
||||
return payment
|
||||
|
||||
|
||||
|
@ -145,7 +145,6 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
||||
def set_recorded(self, user: User) -> UserActionLogEntry:
|
||||
log_entry = super().set_recorded(user)
|
||||
self.add_log_entry_to_compensations(log_entry)
|
||||
self.send_data_to_egon()
|
||||
return log_entry
|
||||
|
||||
def add_log_entry_to_compensations(self, log_entry: UserActionLogEntry):
|
||||
@ -183,6 +182,8 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
||||
intervention=self,
|
||||
)
|
||||
self.mark_as_edited(user, form.request, edit_comment=PAYMENT_ADDED)
|
||||
|
||||
self.send_data_to_egon()
|
||||
return pay
|
||||
|
||||
def add_revocation(self, form):
|
||||
@ -347,6 +348,7 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
||||
with transaction.atomic():
|
||||
payment.delete()
|
||||
self.mark_as_edited(user, request=form.request, edit_comment=PAYMENT_REMOVED)
|
||||
self.send_data_to_egon()
|
||||
|
||||
|
||||
class InterventionDocument(AbstractDocument):
|
||||
|
@ -156,10 +156,20 @@ class EgonGmlBuilder:
|
||||
|
||||
def build_gml(self):
|
||||
comp_type, comp_type_code = self._gen_kompensationsArt()
|
||||
payment_date = self.intervention.payments.first().due_on
|
||||
if payment_date is not None:
|
||||
payment = self.intervention.payments.first()
|
||||
payment_date = None
|
||||
if payment is not None:
|
||||
payment_date = payment.due_on
|
||||
payment_date = payment_date.strftime(DEFAULT_DATE_FORMAT)
|
||||
|
||||
cons_office = self.intervention.responsible.conservation_office
|
||||
reg_office = self.intervention.responsible.registration_office
|
||||
law = self.intervention.legal.laws.first()
|
||||
process_type = self.intervention.legal.process_type
|
||||
handler = self.intervention.responsible.handler
|
||||
reg_date = self.intervention.legal.registration_date
|
||||
bind_date = self.intervention.legal.binding_date
|
||||
|
||||
xml_dict = {
|
||||
"wfs:FeatureCollection": {
|
||||
"@xmlns:wfs": "http://www.opengis.net/wfs",
|
||||
@ -174,12 +184,12 @@ class EgonGmlBuilder:
|
||||
"oneo:azZulassungsstelle": self.intervention.responsible.registration_file_number,
|
||||
"oneo:bemerkungZulassungsstelle": None,
|
||||
"oneo:eintragungsstelle": {
|
||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/907/{self.intervention.responsible.conservation_office.atom_id}",
|
||||
"#text": self.intervention.responsible.conservation_office.long_name
|
||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/907/{cons_office.atom_id if cons_office else None}",
|
||||
"#text": cons_office.long_name if cons_office else None
|
||||
},
|
||||
"oneo:zulassungsstelle": {
|
||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1053/{self.intervention.responsible.registration_office.atom_id}",
|
||||
"#text": self.intervention.responsible.registration_office.long_name
|
||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1053/{reg_office.atom_id if reg_office else None}",
|
||||
"#text": reg_office.long_name if reg_office else None
|
||||
},
|
||||
"oneo:ersatzzahlung": self._sum_all_payments(),
|
||||
"oneo:kompensationsart": {
|
||||
@ -187,20 +197,20 @@ class EgonGmlBuilder:
|
||||
"#text": comp_type
|
||||
},
|
||||
"oneo:verfahrensrecht": {
|
||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1048/{self.intervention.legal.laws.first().atom_id}",
|
||||
"#text": self.intervention.legal.laws.first().short_name
|
||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1048/{law.atom_id if law else None}",
|
||||
"#text": law.short_name if law else None
|
||||
},
|
||||
"oneo:verfahrenstyp": {
|
||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/44382/{self.intervention.legal.process_type.atom_id}",
|
||||
"#text": self.intervention.legal.process_type.long_name,
|
||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/44382/{process_type.atom_id if process_type else None}",
|
||||
"#text": process_type.long_name if process_type else None,
|
||||
},
|
||||
"oneo:eingreifer": {
|
||||
"oneo:Eingreifer": {
|
||||
"oneo:art": {
|
||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1053/{self.intervention.responsible.handler.type.atom_id}",
|
||||
"#text": self.intervention.responsible.handler.type.long_name,
|
||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1053/{handler.type.atom_id if handler.type else None}",
|
||||
"#text": handler.type.long_name if handler.type else None,
|
||||
},
|
||||
"oneo:bemerkung": self.intervention.responsible.handler.detail,
|
||||
"oneo:bemerkung": handler.detail if handler else None,
|
||||
}
|
||||
},
|
||||
"oneo:erfasser": {
|
||||
@ -212,8 +222,8 @@ class EgonGmlBuilder:
|
||||
"oneo:zulassung": {
|
||||
"oneo:Zulassungstermin": {
|
||||
"oneo:bauBeginn": payment_date,
|
||||
"oneo:erlass": self.intervention.legal.registration_date.strftime(DEFAULT_DATE_FORMAT),
|
||||
"oneo:rechtsKraft": self.intervention.legal.binding_date.strftime(DEFAULT_DATE_FORMAT),
|
||||
"oneo:erlass": reg_date.strftime(DEFAULT_DATE_FORMAT) if reg_date else None,
|
||||
"oneo:rechtsKraft": bind_date.strftime(DEFAULT_DATE_FORMAT) if bind_date else None,
|
||||
}
|
||||
},
|
||||
"oneo:geometrie": {
|
||||
|
Loading…
Reference in New Issue
Block a user