Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export des relevés - Ajout d'une option "Les relevés sont destinés à des tiers" #378

Merged
merged 2 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ cadastre.*.zip
# Temp files
*~
*.bak

# VSCode
*.code-workspace
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

* Export des relevés - Ajout d'une option "Les relevés sont destinés à des tiers"
qui permet de ne pas faire figurer la date et le lieu de naissance des propriétaires dans les PDF.

## 1.15.1 - 2022-08-12

Expand Down
17 changes: 15 additions & 2 deletions cadastre/cadastre_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _printProgress(self, nb: int) -> Generator[Callable[[int], None], None, None
class CadastreExport:

def __init__(self, project: QgsProject, layer: QgsMapLayer, etype: str, comptecommunal: str,
geo_parcelle: str = None, target_dir: str = None) -> None:
geo_parcelle: str = None, target_dir: str = None, for_third_party: bool = False) -> None:

self.plugin_dir = str(Path(__file__).resolve().parent)

Expand All @@ -81,6 +81,11 @@ def __init__(self, project: QgsProject, layer: QgsMapLayer, etype: str, compteco
# type of export : proprietaire or parcelle
self.etype = etype

# third party export
# If true, remove some sensitive fields
# For example date and location of birth
self.for_third_party = for_third_party

# id of the parcelle
self.geo_parcelle = geo_parcelle

Expand Down Expand Up @@ -292,6 +297,7 @@ def getContentForGivenItem(self, key, item, page=None):

content = ''
replaceDict = ''

# Build template file path
tplPath = os.path.join(
self.plugin_dir,
Expand All @@ -315,6 +321,12 @@ def getContentForGivenItem(self, key, item, page=None):
sql = sql.replace('$schema', '"{}".'.format(self.connectionParams['schema']))
else:
sql = sql.replace('$schema', '')

# Add the for_third_party values
# only useful for proprietaire
# to empty sensitive data (date and location of birth)
sql = sql.replace('$for_third_party', str(self.for_third_party))

# Add where clause depending on etype
sql = sql.replace('$and', item['and'][self.etype])

Expand All @@ -326,9 +338,10 @@ def getContentForGivenItem(self, key, item, page=None):
# Get data from previous fetched full data
data = self.lineCount[key]['data'][offset:self.maxLineNumber + offset]

# Run SQL
# Convert PostgreSQL syntax to SQLite
if self.dbType == 'spatialite':
sql = cadastre_common.postgisToSpatialite(sql)

# Run SQL only if data has not already been defined
if data is None:
# print(sql)
Expand Down
4 changes: 2 additions & 2 deletions cadastre/dialogs/cadastre_export_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ def printProgress(self, nb: int) -> Generator[Callable[[int], None], None, None]
class CadastreExport(cadastreExportBase):

def __init__(self, layer: QgsMapLayer, etype: str, comptecommunal: str,
geo_parcelle: str = None, target_dir: str = None) -> None:
geo_parcelle: str = None, target_dir: str = None, for_third_party: bool = False) -> None:

self.mProgress = printProgress

super().__init__(QgsProject.instance(),
layer, etype, comptecommunal, geo_parcelle, target_dir)
layer, etype, comptecommunal, geo_parcelle, target_dir, for_third_party)

self.print_parcelle_page = True

Expand Down
8 changes: 7 additions & 1 deletion cadastre/dialogs/parcelle_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(self, iface, layer, feature, cadastre_search_dialog, parent=None):
self.rejected.connect(self.onReject)
self.buttonBox.rejected.connect(self.onReject)
self.buttonBox.accepted.connect(self.onAccept)

# Export buttons
exportButtons = {
'parcelle': self.btExportParcelle,
Expand Down Expand Up @@ -416,6 +417,9 @@ def export_as_pdf(self, key):
self.proprietairesInfo.setText(u'Pas de données de propriétaires dans la base')
return

# Check if PDF must be exported for a third party or not
for_third_party = self.cbForThirdParty.isChecked()

if self.feature:
comptecommunal = CadastreCommon.getCompteCommunalFromParcelleId(
self.feature['geo_parcelle'],
Expand All @@ -435,7 +439,9 @@ def export_as_pdf(self, key):
self.layer,
key,
comptecommunal,
self.feature['geo_parcelle']
self.feature['geo_parcelle'],
None,
for_third_party
)
qe.export_as_pdf()

Expand Down
21 changes: 19 additions & 2 deletions cadastre/dialogs/search_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,16 @@ def export_proprietaire(self):
return

layer = self.searchComboBoxes['proprietaire']['layer']
qex = CadastreExport(QgsProject.instance(), layer, 'proprietaire', cc)

# If export are for third-party persons
# we need to remove sensitive data
for_third_party = self.cbForThirdParty.isChecked()

qex = CadastreExport(
QgsProject.instance(), layer, 'proprietaire', cc,
None, None,
for_third_party
)

with OverrideCursor(Qt.WaitCursor):
exports = qex.export_as_pdf()
Expand Down Expand Up @@ -1250,13 +1259,21 @@ def exportParcelle(self, key):
self.qc.updateLog('Aucune parcelle sélectionnée !')
return

# Get id of the owner
compte_communal = CadastreCommon.getCompteCommunalFromParcelleId(
feature['geo_parcelle'],
self.connectionParams,
self.connector
)

# If export are for third-party persons
# we need to remove sensitive data
for_third_party = self.cbForThirdParty.isChecked()
qex = CadastreExport(
QgsProject.instance(), layer, 'parcelle', compte_communal, feature['geo_parcelle'])
QgsProject.instance(), layer, 'parcelle',
compte_communal, feature['geo_parcelle'],
None, for_third_party
)

with OverrideCursor(Qt.WaitCursor):
exports = qex.export_as_pdf()
Expand Down
74 changes: 50 additions & 24 deletions cadastre/forms/cadastre_parcelle_form.ui
Original file line number Diff line number Diff line change
Expand Up @@ -120,65 +120,90 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="btExportParcelle">
<widget class="QPushButton" name="btCentrer">
<property name="text">
<string>Relevé parcellaire</string>
<string>Centrer</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="btExportProprietaire">
<widget class="QPushButton" name="btZoomer">
<property name="text">
<string>Relevé de propriété</string>
<string>Zoomer</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbExportAllCities">
<widget class="QPushButton" name="btSelectionner">
<property name="text">
<string>Exporter pour toutes les communes</string>
<string>Sélect.</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="btCentrer">
<widget class="QPushButton" name="btParcellesProprietaire">
<property name="text">
<string>Centrer</string>
<string>Sélectionner les parcelles du propriétaire</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Export</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="cbForThirdParty">
<property name="toolTip">
<string>Lorsque cette case est cochée, les dates et lieux de naissance des propriétaires ne sont pas exportés dans les relevés PDF.</string>
</property>
<property name="text">
<string>Les relevés sont destinés à des tiers</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btZoomer">
<widget class="QPushButton" name="btExportParcelle">
<property name="text">
<string>Zoomer</string>
<string>Relevé parcellaire</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="btSelectionner">
<widget class="QPushButton" name="btExportProprietaire">
<property name="text">
<string>Sélect.</string>
<string>Relevé de propriété</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="btParcellesProprietaire">
<widget class="QCheckBox" name="cbExportAllCities">
<property name="toolTip">
<string>Cocher cette case permet d'exporter le relevé de propriété pour toutes les communes. Cela peut être très long !</string>
</property>
<property name="text">
<string>Sélectionner les parcelles du propriétaire</string>
<string>Exporter pour toutes les communes</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -208,5 +233,6 @@
<tabstop>btSelectionner</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
50 changes: 34 additions & 16 deletions cadastre/forms/cadastre_search_form.ui
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>586</height>
<width>436</width>
<height>573</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
Expand Down Expand Up @@ -229,15 +229,13 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<!--commune proprietaire label-->
<item row="1" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Commune</string>
</property>
</widget>
</item>
<!--reset commune proprietaire-->
<item row="1" column="2">
<widget class="QToolButton" name="btResetCommuneProprietaire">
<property name="toolTip">
Expand All @@ -248,7 +246,6 @@
</property>
</widget>
</item>
<!--commune priprietaire combo-->
<item row="1" column="1">
<widget class="QComboBox" name="liCommuneProprietaire">
<property name="sizePolicy">
Expand All @@ -272,17 +269,16 @@
</property>
</widget>
</item>
<!--Checkbox-->
<item row="0" column="1">
<widget class="QCheckBox" name="cbSearchNameBirth">
<property name="text">
<string>Rechercher par nom de naissance</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="cbSearchNameBirth">
<property name="text">
<string>Rechercher par nom de naissance</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="liParcelleProprietaire">
<property name="sizePolicy">
Expand Down Expand Up @@ -398,6 +394,28 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="grpOptions">
<property name="title">
<string>Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="cbForThirdParty">
Gustry marked this conversation as resolved.
Show resolved Hide resolved
<property name="toolTip">
<string>Lorsque cette case est cochée, les dates et lieux de naissance des propriétaires ne sont pas exportés dans les relevés PDF.</string>
</property>
<property name="text">
<string>Les relevés sont destinés à des tiers</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTextEdit" name="txtLog">
<property name="html">
Expand Down
Loading