1414# PyQGIS
1515from qgis .core import Qgis
1616from qgis .PyQt import uic
17+ from qgis .PyQt .QtCore import QDate
1718from qgis .PyQt .QtWidgets import QDialog , QDialogButtonBox , QWidget
1819
1920# plugin
2021from qtribu .__about__ import __title__ , __version__
21- from qtribu .constants import ICON_ARTICLE , contribution_guides_base_url
22+ from qtribu .constants import (
23+ ARTICLE_ISSUE_FORM_NAME ,
24+ ICON_ARTICLE ,
25+ SOURCE_REPOSITORY_URL ,
26+ contribution_guides_base_url ,
27+ )
28+ from qtribu .gui .wdg_authoring import AuthoringWidget
29+ from qtribu .gui .wdg_editing_compliance import EditingPolicyWidget
2230from qtribu .toolbelt import NetworkRequestsManager , PlgLogger , PlgOptionsManager
2331from qtribu .toolbelt .commons import open_url_in_browser
2432
2533
2634class ArticleForm (QDialog ):
2735 """QDialog form to submit an article."""
2836
29- ISSUE_FORM_BASE_URL : str = (
30- "https://github.com/geotribu/website/issues/new?template=ARTICLE.yml"
31- )
37+ # type hints for sub-widgets
38+ wdg_author : AuthoringWidget
39+ wdg_editing_compliance : EditingPolicyWidget
3240
3341 def __init__ (self , parent : Optional [QWidget ] = None ):
3442 """Constructor.
@@ -43,20 +51,14 @@ def __init__(self, parent: Optional[QWidget] = None):
4351 self .plg_settings = PlgOptionsManager ()
4452 self .qntwk = NetworkRequestsManager ()
4553
54+ # initialize GUI
55+ self .initGui ()
56+
57+ def initGui (self ) -> None :
58+ """Initialize GUI elements."""
4659 # custom icon
4760 self .setWindowIcon (ICON_ARTICLE )
4861
49- # publication
50- self .cbb_license .addItems (
51- [
52- "Creative Commons International BY-NC-SA 4.0" ,
53- "Creative Commons International BY-SA 4.0" ,
54- "Creative Commons International BY 4.0" ,
55- "Beerware (Révision 42)" ,
56- "autre - merci de préciser dans le champ libre en fin de formulaire" ,
57- ]
58- )
59-
6062 # connect help button
6163 self .btn_box .helpRequested .connect (
6264 partial (
@@ -72,6 +74,27 @@ def __init__(self, parent: Optional[QWidget] = None):
7274 self .tr ("Submit" )
7375 )
7476
77+ # custom sub-widget
78+ self .wdg_editing_compliance .chb_license_rdp .setEnabled (False )
79+ self .wdg_editing_compliance .chb_transparency .setText (
80+ self .wdg_editing_compliance .chb_transparency .text ()
81+ + self .tr ("\n If not, I give some details in the comment area." )
82+ )
83+
84+ # set the minimum proposed date to 2 weeks from
85+ today : QDate = QDate .currentDate ()
86+ min_date : QDate = today .addDays (14 )
87+ self .dte_proposed_date .setMinimumDate (min_date )
88+
89+ @property
90+ def issue_form_url (self ) -> str :
91+ """Get Github issue form base URL.
92+
93+ :return: issue form base URL
94+ :rtype: str
95+ """
96+ return f"{ SOURCE_REPOSITORY_URL } issues/new?&template={ ARTICLE_ISSUE_FORM_NAME } "
97+
7598 def check_required_fields (self ) -> bool :
7699 invalid_fields = []
77100 error_message = ""
@@ -153,16 +176,17 @@ def on_btn_submit(self) -> Union[bool, str, None]:
153176 if not self .check_required_fields ():
154177 return False
155178
156- completed_url = (
157- f"{ self .ISSUE_FORM_BASE_URL } "
179+ completed_url : str = (
180+ f"{ self .issue_form_url } "
158181 f"&in_author_name={ self .wdg_author .lne_firstname .text ()} "
159182 f"{ self .wdg_author .lne_lastname .text ()} "
160183 f"&in_author_mail={ self .wdg_author .lne_email .text ()} "
161184 f"&in_author_linkedin={ self .wdg_author .lne_linkedin_account .text ()} "
162185 f"&in_author_mastodon={ self .wdg_author .lne_mastodon_account .text ()} "
163186 f"&in_author_twitter={ self .wdg_author .lne_twitter_account .text ()} "
164187 f"&in_author_license=true"
165- f"&cb_author_content_relationship={ self .chb_transparency .isChecked ()} "
188+ f"&cb_author_content_relationship={ self .wdg_editing_compliance .chb_transparency .isChecked ()} "
189+ f"&cb_author_aware_ai_guidelines={ self .wdg_editing_compliance .chb_genai_editing_policy .isChecked ()} "
166190 f"&in_art_title={ self .lne_title .text ()} "
167191 f"&in_art_date={ self .dte_proposed_date .date ().toString ('dd/MM/yyyy' )} "
168192 f"&tx_art_content={ self .txt_description .toPlainText ()} "
@@ -171,7 +195,7 @@ def on_btn_submit(self) -> Union[bool, str, None]:
171195 f"&title=[Proposition] { self .lne_title .text ()} - { __title__ } { __version__ } "
172196 )
173197 self .log (message = f"Opening issue form: { completed_url } " , log_level = 4 )
174- url_opened = open_url_in_browser (url = completed_url )
198+ url_opened : bool = open_url_in_browser (url = completed_url )
175199 if url_opened :
176200 self .log (
177201 message = self .tr ("Issue form URL opened in default system web browser." ),
0 commit comments