From a3858ff048e710879b9b60898adac2cf549b5d46 Mon Sep 17 00:00:00 2001 From: kerem Date: Mon, 12 Aug 2024 18:30:15 +0200 Subject: [PATCH] Started using htmx for dynmical fileds, now need to implment it sitewide, or make an formular for address only let's see --- web/$ | 79 ++++++++++++++++++ web/minibase/__pycache__/app.cpython-311.pyc | Bin 2309 -> 2484 bytes .../__pycache__/theme.cpython-311.pyc | Bin 2914 -> 3449 bytes web/minibase/app.py | 2 + .../company/__pycache__/forms.cpython-311.pyc | Bin 3101 -> 3074 bytes .../__pycache__/routes.cpython-311.pyc | Bin 7283 -> 7585 bytes .../company/__pycache__/utils.cpython-311.pyc | Bin 3443 -> 4500 bytes web/minibase/blueprints/company/forms.py | 9 +- web/minibase/blueprints/company/routes.py | 67 ++++++++------- web/minibase/blueprints/company/utils.py | 21 +++++ .../__pycache__/forms.cpython-311.pyc | Bin 0 -> 1291 bytes .../__pycache__/routes.cpython-311.pyc | Bin 0 -> 4569 bytes .../__pycache__/utils.cpython-311.pyc | Bin 3175 -> 3175 bytes web/minibase/blueprints/geography/forms.py | 11 +++ web/minibase/blueprints/geography/routes.py | 52 ++++++++++++ .../templates/geography/city_options.html | 3 + .../geography/templates/geography/index.html | 12 +++ web/minibase/blueprints/geography/utils.py | 26 +++--- web/minibase/templates/base.html | 2 + web/minibase/templates/form.html | 3 + web/minibase/templates/form/fileField.html | 17 ++++ .../templates/form/selectFieldHor.html | 4 +- .../templates/form/selectFieldVer.html | 4 +- web/minibase/templates/form/stringField.html | 2 + web/minibase/templates/form/urlField.html | 15 ++++ web/minibase/theme.py | 37 ++++++-- 26 files changed, 307 insertions(+), 59 deletions(-) create mode 100644 web/$ create mode 100644 web/minibase/blueprints/geography/__pycache__/forms.cpython-311.pyc create mode 100644 web/minibase/blueprints/geography/__pycache__/routes.cpython-311.pyc create mode 100644 web/minibase/blueprints/geography/forms.py create mode 100644 web/minibase/blueprints/geography/routes.py create mode 100644 web/minibase/blueprints/geography/templates/geography/city_options.html create mode 100644 web/minibase/blueprints/geography/templates/geography/index.html create mode 100644 web/minibase/templates/form/fileField.html create mode 100644 web/minibase/templates/form/urlField.html diff --git a/web/$ b/web/$ new file mode 100644 index 00000000..2015a147 --- /dev/null +++ b/web/$ @@ -0,0 +1,79 @@ +from flask import render_template, url_for, flash, redirect, request, Blueprint +from flask_login import login_required, current_user +from minibase.app import db +import minibase.theme as theme +from minibase.blueprints.company.models import Companies +import minibase.blueprints.database.utils as dbUtils +import minibase.blueprints.main.utils as mainUtils +import minibase.blueprints.geography.utils as geoUtils +import minibase.blueprints.company.utils as companyUtils +from minibase.blueprints.company.forms import updateCompanyForm +from minibase.blueprints.user.utils import save_picture +from flask_wtf import FlaskForm + + +# Declaring a blueprint +company = Blueprint('company', __name__, template_folder='templates') + +@company.route("/list", methods=['GET', 'POST']) +def list(): + page=request.args.get('page', 1, type=int) + table=dbUtils.table_printable_paginate(Companies, page, 20, 'edit/', 'id') + return(render_template('view.html', theme=theme, table=table, title="Companies")) + + +@company.route("/edit/", methods=['GET', 'POST']) +@login_required +def edit_company(companyId): + if id: + form = updateCompanyForm() + company = companyUtils.queryById(companyId) + form.city.choices = [(row.id, row.name) for row in geoUtils.queryCiytNamesOfStateWithDefId(company.city_id, company.state_id)] + form.state.choices = [(row.id, row.name) for row in geoUtils.queryStateNamesOfCuntryWithDefId(company.state_id, company.country_id)] + form.country.choices = [(row.id, row.name) for row in geoUtils.queryCountryNamesWithDefault(company.country_id)] + form.industry.choices = [(row.id, row.name) for row in mainUtils.queryIndustryNamesWithDefault(company.industry_id)] + form.legal_entity.choices = [(row.id, row.name) for row in companyUtils.queryLegalEntityNames()] + form.type.choices = [(row.id, row.name) for row in companyUtils.queryTypeNames()] + form.relation.choices = [(row.id, row.name) for row in companyUtils.queryRelationNames()] + form.status.choices = [(row.id, row.name) for row in companyUtils.queryStatusNames()] + + if form.validate_on_submit(): + comp = Companies( + name = form.name.data, + street = form.street.data, + website = form.website.data, + street_no = form.street_no.data, + post_code = form.post_code.data, + city_id = form.city.data, + state_id = form.state.data, + country_id = form.country.data, + industry_id = form.industry.data, + legal_entity_id = form.legal_entity.data, + type_id = form.type.data, + relation_id = form.relation.data, + status_id = form.status.data, + comment = form.comment.data) + flash('Company Has been successfully updated', 'success') + return redirect(url_for('company.edit', companyId)) + elif request.method == 'GET': + form.name.data = company.name + form.website.data = company.website + form.street.data = company.street + form.street_no.data = company.street_no + form.post_code.data = company.post_code + + form.comment.data = company.comment + # This could be very interesting but neds more time to think ! + #for field in form: + # if field.name != 'csrf_token' and hasattr(company, field.name): + # attr = getattr(company, field.name) + # field.data = attr + image_file = url_for('static', filename='pics/' + companyUtils.queryImageById(companyId)) + + return render_template('company/account.html', + theme=theme, + image_file=image_file, + form=form) + else: + flash('You need to select a company id', 'alarm') + return redirect(url_for('company.list')) diff --git a/web/minibase/__pycache__/app.cpython-311.pyc b/web/minibase/__pycache__/app.cpython-311.pyc index 5e2025d6a7b8479245a7685dd6b9a02afa7ec86f..b9e2b23e5500481a28729c15866713f515b60626 100644 GIT binary patch delta 413 zcmZn_+9J%ioR^o20SJ~$>`L?D*vL1Tk+Ea*BF3qV0x66sY&pWYBDJiH3^fc3L?`<* ziLx@Lu&?2mypdU$5yEFm;Y8sxr*NV0SyH%B_^c^BK>mGZQAXa$UzxReG#PJkrl;no z7bO;COqOTS;j7}(hw&>l#U}f*d{31VDr!kSJyY5(<;cS?#z~fGio1P~znMtY?I7 zu-IKdMU%VP(j;%NuwQ49y2K(i!*YYn1s17`EOuAG$|iqgTh1*G)L$eCBBUlSX4lY? z1~PB47pE2%XXfV>foxdGP^1cyR|XQlIBatBQ%ZAE?TU;he`Wt7qs++vfdP{M>i__= CY;INn delta 283 zcmdlY+$zMkoR^o20SMeKPe?n*zL9S-BctEuMT}D!S!x&-2v5GqEXvB5!nTHeaw4-Z zBZSYC!hynPPT@r2i%W8?VPD3?z_1#KA%Kygh9Q_ilY6p0i}vJn7HuX?k;w~KzE3{H zDk9H%i#f5NpokZ!vWO2v@Ph~eAW_T;Bqsl6wc}C(GGss^W|N)S&P-NhPn*1eeL1%n zP^d@(L`Y5!;?U5N0y1y07pE2%XXfV>fi$gTC{hN=D*}mM95%W6DWy57c0~r0mvDTM OQDo%*z<^1BbpQafMnL=k diff --git a/web/minibase/__pycache__/theme.cpython-311.pyc b/web/minibase/__pycache__/theme.cpython-311.pyc index f495e65237805449c615c1c31259ab7cb733d43d..fc6b5424a702a0ae3bb80744fe9a375b0e5d1063 100644 GIT binary patch delta 988 zcmZWoJ#W)M7_Mt4Ax`b2%@H2t9M!vX5YGepJ;m9a_!I7nu2h$wiL`tTgo!c@T#qT(pjW1z)B zy9nAP62u6!dC(G|B}oV`5FZs=a1NQ}NEaPG#}TJU7%!0sUIzbV@UH+*s}OL7MDZ$# zZB1q3?A`QBVU?A{L?Bf&^R>h0nqDKUATBa2-n>4Lsx_UqBF`+VX_kvc`a-KWbz0bO z)Qhdyo^_alnb!|e)rL{en^dR!7W*M)*=uo4e4JThg0x-^6I#`dbZb}F_NczQuWP0` z@HPzX@PH1^6;10{KNDF_T4Y<&PCLXOV`Bff;%<^1kDKmyxOLp51J_6mqhXAW4jvi$ zMAn$#M)|qJO$u;&chteaagJxrxjj$BO=>)m^`sT{K}xnmM6=HIF{X_Aa1{4+*FS!s z->LG>j2ZaIhQdMR5c&(8m?r@CztKnePo5rPYo0_q-bc%CpY+hxZehEJw!0Dt_W_3} z-<6`^ba36SxO9keV{*=}IKGHe1WenH`Y2^Tbk|U`H-U0UbFt*a*qhF#7&mz&xLsqf zJPX+&D%%@X zg)fRfg+EFlMIcHrMKDSzg*}xSq$))SM5YRZ*FGJClhs(XnEikz zRI^x2{>381af>a#C^0WRbutfYb$^^)NAf*Eq)diC}4c-r=tQvf7NXaz# zd|+dcR&4ORA!P;CdF24V{e#&6 diff --git a/web/minibase/app.py b/web/minibase/app.py index c090b4c2..9f7ee853 100644 --- a/web/minibase/app.py +++ b/web/minibase/app.py @@ -49,6 +49,7 @@ def create_app(): from minibase.blueprints.user.routes import user from minibase.blueprints.errors.routes import errors from minibase.blueprints.company.routes import company + from minibase.blueprints.geography.routes import geography # (BLUEPRINTS) Registering the blueprints. # Giving them theie ulr_prefixes that will define their links on the webBrowser. @@ -56,6 +57,7 @@ def create_app(): app.register_blueprint(user, url_prefix='/user') app.register_blueprint(errors, url_prefix='/errors') app.register_blueprint(company, url_prefix='/company') + app.register_blueprint(geography, url_prefix='/geography') # (APP) Returning the initialised app return app diff --git a/web/minibase/blueprints/company/__pycache__/forms.cpython-311.pyc b/web/minibase/blueprints/company/__pycache__/forms.cpython-311.pyc index bbd5348097b5bede9a7878b001f9a5b9ca2495b8..cbed8debe199a1c9d13c8291d2e50f267a378dfb 100644 GIT binary patch delta 379 zcmbO$(ImmUoR^o20SL4WccnROiu55#5_ z0-IOJtPM1OE;C4tAXv=@<_GHR&iSQzB}J9DSe!FUfMh^^amg*#;F83W)LU%9B}J*J zCAXOT@;85Hxx&aOJNXP-uU!$y?YG#IVH%Tx8jCnVVw?p)-SNr!DXF(uiy=l7LyX{r z(D8Zslc%%SFe*(J;V7Ie#wj~Fms4``ZVpAh^bJZEgiJ3AnO+exZE&5ukW+s0JPz5( k`kdbw**2?jZDVwlWDH~cz<`~c!TAv^^96@|kv`CQ0O~wx_y7O^ delta 397 zcmZpYm@C1%oR^o20SGjVwxtDcDa$K;Jns_fig zHYb?P17!22aDmvYd?5DZ^-S8#yeT|jSpl#tFPJR|X7hnn3V~I|GlNtLfMrF%vVtJ? zsd>R~Q-P zChubFwY$Yu4AxV`3G~J-P6#JHFaH*20Z@N@a(+r`5y*?TSdzge6+=u)hL|+DmA!^h zdomM8;pBT9W|LQPC{7OIl$A)|V6(wyqumy}3r0>Cgq$x5IbRWSZg9OZIgdkWaz3Z* pWK+(oj2x2%xx_XraxGwVlwu5H{J?;noWc1KEb|42e33rTbpV4}ap3>} diff --git a/web/minibase/blueprints/company/__pycache__/routes.cpython-311.pyc b/web/minibase/blueprints/company/__pycache__/routes.cpython-311.py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W$vfsoGmJOO#5pSPzr4vK=oIU+V^9ll_IzuY zm+2Hsujb_C)6!z5T#(TP=5euitcudi<1F*=agR%EozL)P=3bg(@5*Z~PWlmDdu~O3 z=IP)xe0n%v~F&_!VA-~@j8@Cn&+o4W(qlx)t;8GRDP?NlM(yq@M35tYRR-J z!0N)wfL>(UJQeuQzGGGXBVy5PJ4<+8MC=Gh>_3DSjMf8PVydOM$`-f8{w~7&;wOaW zkmxJ8u;YxDsFls9lr*vp``iMAu4mvo=E-e$SanBc*C!Hrif?CP_yDU z`m}0;@9n?Ll6gs;Un28MbX%*jWfEJinTX&gLZrcW?2}nCb4{Ijjm*48cd8n=P6F3! zrUy34Y48pBq(bI?tj^seb2sV6Q^Oe&&QOAr2*C#5SWn(0r(Rc2QTZm_P-^G~3Eikw zO%Lou7T`<(!>_C-kt* zpsRQC8KB}DCTgdjhk(%1CBlR#Sa&JpjN;+VtQ zz=i75@S$~g?ev37#1VY%0E3bGz}DF(1(Lq5yq;ClB1wztaZ&M0s$U|0sdnLM-;~m7 zCq$*y7VjuNRQvuv-63W8#CAN{NS(`M>UJ_A&I!$cF9Y)P8L=2Bd#t$tOQ zCP86Z5vI4@{U2ECE_EP922!efg19FXVS=87U-~5&z%LK_@!a557{%`oj=@*)mxISG zudp{Qf|G**+&A=#7&~A2D~0$ciXDCYrTdRCTf8Nf3sM^W{L{xnWjOM)x^Kf$cfTD} z;RJybO@k3$gH6EXGb1oeQVjnvI68h3PBsA*4D7xiVvp}Z0>9fd=@xG0r|ka#-a5|0 diff --git a/web/minibase/blueprints/company/__pycache__/utils.cpython-311.pyc b/web/minibase/blueprints/company/__pycache__/utils.cpython-311.pyc index 2e746b0cd4da5981a5770d64eea91b0e5c91715b..82aedb86ac8394ae23d84c425db4d4e550ec55e9 100644 GIT binary patch delta 1166 zcmbu7&rcIU6vt;4cDLPbr~D}8rvX7FjcqlGicmCCz!*pmA~BMvS(vS^X$#J74JMX>Srk5S$ zZ7`@ISi4_8XPVU_X}}A`&h|M(rL2-uCnbz>K9Bx!4I^6d9E}HPB~Yg_Fh~_3p(-#$ zeZVT}2Ub%JSVIHATB-xXGzhGt1Q?+qU_Gq@Hc)94MXP@b5mDLor>1h#M)6e|r}+&z zQrz3aGT)LSJS44Q|MHepiMwkf zKlJrt%s=_Vz8;8OL=NUfH9Y53g7tUJq9qBT53v8NXLuHmB6b?AXoaiNi805@+HT}& z!DKUOBWK>VoW}!Z#wcW+Ta<}R?<7~IW(KS%Shh&j*2Y5ca@)LPBjzI`JD7JY$IB46 z59MIzA?}Pg*94eH-$-4F#JKOthGZ_AyaCCJMunJgql{ wQ}Bsl+xLJw6&T|kiNDd$@z;9CsZG?i{=bK>>5IHO7>6AqNW!%{0^W6g1A$>0`~Uy| delta 289 zcmbQD{8@@`IWI340}wo{o0xW)Wg?#hW86e_B}b+fhA6faW+2I)!U7~YQdof`X9^pT z^hS}SRSznBDfi>&l$xw2e64VGD=SlU^AXPoBa!;!sH1Y z){}F2=S~jdvSif(s#cvmfy)XkqRC^+ss|L&nw-r8QgegV0Lasy?8Rrv?58O(*^}RP z@)>>=Zji1bkisH^$@~IRBE~=_BM=w=1QH*Z85tQrFilPr(3>1DpgMVrz_iJ2f_wmM CFh+m? diff --git a/web/minibase/blueprints/company/forms.py b/web/minibase/blueprints/company/forms.py index 72543e3a..cc1a1d96 100644 --- a/web/minibase/blueprints/company/forms.py +++ b/web/minibase/blueprints/company/forms.py @@ -8,12 +8,12 @@ class updateCompanyForm(FlaskForm): # Defines the form class to be used for the name = StringField('Name', validators=[DataRequired(), Length(min=3, max=100)]) website = URLField('Website', validators=[DataRequired(), Length(min=3, max=100)]) + country = SelectField('Country', validators=[DataRequired()]) + city = SelectField('City', validators=[DataRequired()]) + post_code = IntegerField('Post', validators=[DataRequired()]) + state = SelectField('State', validators=[]) street = StringField('Street', validators=[DataRequired()]) street_no = IntegerField('No', validators=[DataRequired()]) - post_code = IntegerField('Post', validators=[DataRequired()]) - city = SelectField('City', validators=[DataRequired()]) - state = SelectField('State', validators=[DataRequired()]) - country = SelectField('Country', validators=[DataRequired()]) industry = SelectField('Industry', validators=[DataRequired()]) legal_entity= SelectField('Legal Entity', validators=[DataRequired()]) type = SelectField('Type', validators=[DataRequired()]) @@ -24,7 +24,6 @@ class updateCompanyForm(FlaskForm): # Defines the form class to be used for the image_file = FileField('Update company Picture', validators=[FileAllowed(['jpg', 'png'])]) submit = SubmitField('Update') - # Queries to be made in order to validate the form : If username exists def validate_companyName(self, company_name): diff --git a/web/minibase/blueprints/company/routes.py b/web/minibase/blueprints/company/routes.py index c98edfa7..cb27717e 100644 --- a/web/minibase/blueprints/company/routes.py +++ b/web/minibase/blueprints/company/routes.py @@ -15,7 +15,7 @@ from flask_wtf import FlaskForm # Declaring a blueprint company = Blueprint('company', __name__, template_folder='templates') -@company.route("/list", methods=['GET', 'POST']) +@company.route("/", methods=['GET', 'POST']) def list(): page=request.args.get('page', 1, type=int) table=dbUtils.table_printable_paginate(Companies, page, 20, 'edit/', 'id') @@ -25,58 +25,57 @@ def list(): @company.route("/edit/", methods=['GET', 'POST']) @login_required def edit_company(companyId): - if id: + if companyId: + company = Companies.query.get_or_404(companyId) form = updateCompanyForm() - company = companyUtils.queryById(companyId) form.city.choices = [(row.id, row.name) for row in geoUtils.queryCiytNamesOfStateWithDefId(company.city_id, company.state_id)] form.state.choices = [(row.id, row.name) for row in geoUtils.queryStateNamesOfCuntryWithDefId(company.state_id, company.country_id)] form.country.choices = [(row.id, row.name) for row in geoUtils.queryCountryNamesWithDefault(company.country_id)] form.industry.choices = [(row.id, row.name) for row in mainUtils.queryIndustryNamesWithDefault(company.industry_id)] - form.legal_entity.choices = [(row.id, row.name) for row in companyUtils.queryLegalEntityNames()] - form.type.choices = [(row.id, row.name) for row in companyUtils.queryTypeNames()] - form.relation.choices = [(row.id, row.name) for row in companyUtils.queryRelationNames()] - form.status.choices = [(row.id, row.name) for row in companyUtils.queryStatusNames()] + form.legal_entity.choices = [(row.id, row.name) for row in companyUtils.queryLegalEntityNamesWithDefault(company.legal_entity_id)] + form.type.choices = [(row.id, row.name) for row in companyUtils.queryTypeNamesWithDefault(company.type_id)] + form.relation.choices = [(row.id, row.name) for row in companyUtils.queryRelationNamesWithDefault(company.relation_id)] + form.status.choices = [(row.id, row.name) for row in companyUtils.queryStatusNamesWithDefault(company.status_id)] if form.validate_on_submit(): - comp = Companies( - name = form.name.data, - street = form.street.data, - website = form.website.data, - street_no = form.street_no.data, - post_code = form.post_code.data, - city_id = form.city.data, - state_id = form.state.data, - country_id = form.country.data, - industry_id = form.industry.data, - legal_entity_id = form.legal_entity.data, - type_id = form.type.data, - relation_id = form.relation.data, - status_id = form.status.data, - comment = form.comment.data) - flash('Company Has been successfully updated', 'success') - return redirect(url_for('company.edit', companyId)) + company.name = form.name.data + company.street = form.street.data + company.website = form.website.data + company.street_no = form.street_no.data + company.post_code = form.post_code.data + company.city_id = form.city.data + company.state_id = form.state.data + company.country_id = form.country.data + company.industry_id = form.industry.data + company.legal_entity_id = form.legal_entity.data + company.type_id = form.type.data + company.relation_id = form.relation.data + company.status_id = form.status.data + company.comment = form.comment.data + flash('Company Has been successfully updated', 'success') + return redirect(url_for('company.edit', companyId=companyId)) elif request.method == 'GET': form.name.data = company.name form.website.data = company.website form.street.data = company.street form.street_no.data = company.street_no form.post_code.data = company.post_code - form.comment.data = company.comment - # This could be very interesting but neds more time to think ! - #for field in form: - # if field.name != 'csrf_token' and hasattr(company, field.name): - # attr = getattr(company, field.name) - # field.data = attr - image_file = url_for('static', filename='pics/' + companyUtils.queryImageById(companyId)) + form.legal_entity.data = company.legal_entity.name + form.type.data = company.type.name - mylist = [['name','website','industry'], ['street','street_no','city','state','country'], 'timestamp'] + image_file = url_for('static', filename='pics/' + companyUtils.queryImageById(companyId)) return render_template('company/account.html', theme=theme, image_file=image_file, - itemList=mylist, form=form) else: flash('You need to select a company id', 'alarm') - return redirect(url_for('company.list')) + return redirect(url_for('company./')) + + # This could be very interesting but neds more time to think ! + #for field in form: + # if field.name != 'csrf_token' and hasattr(company, field.name): + # attr = getattr(company, field.name) + # field.data = attr diff --git a/web/minibase/blueprints/company/utils.py b/web/minibase/blueprints/company/utils.py index b515f147..d84421f4 100644 --- a/web/minibase/blueprints/company/utils.py +++ b/web/minibase/blueprints/company/utils.py @@ -1,4 +1,5 @@ from minibase.blueprints.company.models import Companies, Company_legal_entities, Company_types, Company_status, Company_relations +import minibase.blueprints.database.utils as dbUtils def queryByNameFirst(cname): @@ -34,16 +35,36 @@ def queryLegalEntityNames(): return choices +def queryLegalEntityNamesWithDefault(defId): + choices = dbUtils.queryNameWithDefaultId(Company_legal_entities, defId) + return choices + + def queryTypeNames(): choices = Company_types.query.order_by(Company_types.name.asc()) return choices +def queryTypeNamesWithDefault(defId): + choices = dbUtils.queryNameWithDefaultId(Company_types, defId) + return choices + + def queryRelationNames(): choices = Company_relations.query.order_by(Company_relations.name.asc()) return choices +def queryRelationNamesWithDefault(defId): + choices = dbUtils.queryNameWithDefaultId(Company_relations, defId) + return choices + + def queryStatusNames(): choices = Company_status.query.order_by(Company_status.name.asc()) return choices + + +def queryStatusNamesWithDefault(defId): + choices = dbUtils.queryNameWithDefaultId(Company_status, defId) + return choices diff --git a/web/minibase/blueprints/geography/__pycache__/forms.cpython-311.pyc b/web/minibase/blueprints/geography/__pycache__/forms.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6d43470ac54bf47c904513830f7ba8481144f1b0 GIT binary patch literal 1291 zcma)4zfaph6h1qN?fh^8v`{Khs>0HANZPG!5NZSjRYFLG(n{CCa^g#{xQoNt0Y&PN zp#xLJ27f^cf`Lk%`d1i3Qz)H^#Qs)|(3@1Ebg_xbs~@7@<(PXN9~r@vP( zB>;X3=X%9@#>HoD>;Vf{5(Y$qk|b;y%OnCLBnqQ}AHgxAK!vDKB^uO79L7lkCW2TL zCrJvXhz@m;a>laY!n0dgnMcj2f6WUvS<}(?|8)L~;kJ|NGFSgn&6Wa?NZEa;K zv{J9@9;zXF4MG@ILJ&`onm0Xj1#LEMiY%rqp?b|*XR!rh+L);en@tnHby((|iEYdD zY^T0JsY915y|RN>pU{uo-2(_f$pTQ80g6}>*U=6?Kk9!`laA$%%uo0Z7mNki$gQvn zN2yk{!>{#-?_LHipig0`C8rY9DX3%WoYSm(w8aTcY=td2)Me2*+iNjpt-)JD%h@>7 z45MxmWEd=A7{sxfSlB7U5dDV{Dh7%sxngQ1%*vt_o`UF zpjN(SdwF8l?Xu~j{5C2NoHA~r2ERVf&DW4qqh@2hm9O%;-CUzZhk2erY20w%bJgxY z-SqvPjs5J&#L2|h$#0YX(^r1Fc$zMrrHk#wZgOm=u)B3Ib1-u_dpzqudFdw$r^&)u zve2II>f<{f_Qy~4sWW}5T@nv{aQ&z3Jr=KuxihxCDiyQI(tSTy<&#IF0xK?@sT?C} zrHVKbBv4T)jSD5nVk137Za{rNAWaE~E>v2mi~v8n<|sFyC0B7s!>qS*P0z+IOAI37 z4uTMig|Sr6UlYiXy9tpy=xvf)SK3T?v9t6scg5tmKe#%NNRreA5B2vU}+I{g`oL=4#3Yz}|TyATQ literal 0 HcmV?d00001 diff --git a/web/minibase/blueprints/geography/__pycache__/routes.cpython-311.pyc b/web/minibase/blueprints/geography/__pycache__/routes.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..70bcc6eac38a10b6d046212e9db600a425e3bbec GIT binary patch literal 4569 zcmeGfOKjW7bx2VXC7E{QIJOfjwqz&SsM}iGZ0b6e<83$DY+M9R5vS=!i$aw|%A!q5 z?vSn{uTyvn19bowNP(i+Lk>DDvJT=yE(O}60eb9_G6+~0z(9av4}0?>J>}BAAw^2^ zXN?5{^ipE<_~yNNZysmfPhSW^5W(}{yMN0+_9OH!I&mIv9eMR92BAktL?WXgl}Rxw zn_^W@%A;~APW7g|sxReZD4$jQDxcyl+@l24U@BP0Luy-&WsoXZuszjLryr}+!*zOR zoqoJd@2b;JSaeS5R(n!CYHzC7ntPR#>Z#Nz3->8~Y9tk55Q`+A=$B55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e^iIrV<9ABbfi~`!=Szd*c6m$IvkJG7@fG-2K-;wOA!aoA$_vnJ79jSBu<85JZ zOBmdkHH5*caLE)dZ3~yTgv(XoJyUq^jW|+#(EdL%XWPz!X_#gqOcRh5SePa#(&jWp z!77qfPK?LSD9nvsij zEgZ#3fI?ef=pX?%h1gPqLNA>hp`Nx3n%yG==pVef^rD`} zw7(~OI!znTbeedre$lGJR!Xtl!EVl?u+pm3ulaGRli ze49~2eMal3p?;%v)X+uas8K@~jH5;kjTlFb8X7ka8vE%rG+?xjT^Dx-h- z*l3%qwoRIClPiIjOz?LDza4nkQ~ANhxk_SXpvqh@nG3t@F$Rh|fUiA>eb=R&Lu|-e oe|qD@bKgb>T|a6vqr0q+nPhemg;e5FgVy=&MJzS8GAm*K7vX3RHvj+t literal 0 HcmV?d00001 diff --git a/web/minibase/blueprints/geography/__pycache__/utils.cpython-311.pyc b/web/minibase/blueprints/geography/__pycache__/utils.cpython-311.pyc index 6a3198d77ad18bf979a84ddf77a59fa0b92c088a..3e006a735e095517431c3f1e24ddc6bef7d6be28 100644 GIT binary patch delta 404 zcmaDZ@mzv;IWI340}#j=(^^Deey;FJ@y`rvoMP1~JzQPxM zoiFtgU+RUz$_sozXH;F`s{%UXF{>8P2!+WPSx<@U09mRaQ&AipGWj8k=;VDI-#F!g zazzS2V)7|=C9xu95SJH3@PP;w5TQC*p2J8;AIJn53wNFX@y^RH2RpCg3SY(KZmykd nAg>l_P4?oR4h+_h+_IDZbMu3+02ec(@CODs!2_1`;*kXaDZzQU delta 422 zcmaDZ@mzv;IWI340}$+Y+?IB2BkwmxM%KwJOkbrrfnvpyK%#-+E}!TXKApAU8$vJg zSzqC^o-D%rf{}0XU*?O_LKvz-H<(`Jv%JD*Ir$0OV^(>fy!hlZ?5E@vfh=hZ)gc>H zFY;Mj;j`HMl0}$t@)1t?$+B#&lexJRgmi$4LE4L>fCSJHTzr#lx#SE2FDScTRCd3j z?0!P@jMRC#Q*swQBd>TyUgV3q!WVU&FXa+n%7whL3w$XT`O2^Gl>-fCV&p1P1{zYN z0wgB?WK|I>QU`H)K?EO&&;SvdlLOdHg!F+-kUF@v{KQ*ZPyx2K@(N$&{{ city.name }} +{% endfor %} diff --git a/web/minibase/blueprints/geography/templates/geography/index.html b/web/minibase/blueprints/geography/templates/geography/index.html new file mode 100644 index 00000000..e3b7aeae --- /dev/null +++ b/web/minibase/blueprints/geography/templates/geography/index.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% block content %} +
> +
+ {{ form.hidden_tag() }} + {{ form.country(**{"hx-get": "get_cities", "hx-target": "#city"}) }} + {{ form.city }} + +
+
+{% endblock content %} + diff --git a/web/minibase/blueprints/geography/utils.py b/web/minibase/blueprints/geography/utils.py index b697cfd2..5273520e 100644 --- a/web/minibase/blueprints/geography/utils.py +++ b/web/minibase/blueprints/geography/utils.py @@ -2,12 +2,14 @@ from minibase.blueprints.geography.models import Country, City, State, Region, S import minibase.blueprints.database.utils as dbUtils from sqlalchemy import case + def queryCountryNames(): choices = Country.query.order_by(Country.name.asc()) return choices + def queryCountryNamesWithDefault(defId): - choices = dbUtils.queryNameWithDefaultId(Country,defId) + choices = dbUtils.queryNameWithDefaultId(Country, defId) return choices @@ -15,8 +17,15 @@ def queryStateNames(): choices = State.query.order_by(State.name.asc()) return choices + def queryStateNamesWithDefault(defId): - choices = dbUtils.queryNameWithDefaultId(State,defId) + choices = dbUtils.queryNameWithDefaultId(State, defId) + return choices + + +def queryStateNamesOfCuntryWithDefId(defId, Filterid): + table = State + choices = table.query.order_by(case((table.id == defId, 0), else_=1), table.name.asc()).filter_by(country_id=Filterid) return choices @@ -24,16 +33,13 @@ def queryCityNames(): choices = City.query.order_by(City.name.asc()) return choices + def queryCityNamesWithDefault(defId): - choices = dbUtils.queryNameWithDefaultId(City,defId) + choices = dbUtils.queryNameWithDefaultId(City, defId) return choices -def queryCiytNamesOfStateWithDefId(defId, Filterid): - table=City - choices = table.query.order_by(case((table.id == defId, 0),else_=1), table.name.asc()).filter_by(state_id=Filterid) - return choices -def queryStateNamesOfCuntryWithDefId(defId, Filterid): - table=State - choices = table.query.order_by(case((table.id == defId, 0),else_=1), table.name.asc()).filter_by(country_id=Filterid) +def queryCiytNamesOfStateWithDefId(defId, Filterid): + table = City + choices = table.query.order_by(case((table.id == defId, 0), else_=1), table.name.asc()).filter_by(state_id=Filterid) return choices diff --git a/web/minibase/templates/base.html b/web/minibase/templates/base.html index 3442f390..06e4cde4 100644 --- a/web/minibase/templates/base.html +++ b/web/minibase/templates/base.html @@ -10,6 +10,8 @@ + + {# Title Block : wit Minibase as defauls value : will be overwritten if anothe page has the same title block #} {% block title %}Minibase{% endblock %} diff --git a/web/minibase/templates/form.html b/web/minibase/templates/form.html index 2854705e..4c9b961c 100644 --- a/web/minibase/templates/form.html +++ b/web/minibase/templates/form.html @@ -9,6 +9,9 @@ {% include 'form/selectFieldVer.html' %} {% include 'form/dateField.html' %} {% include 'form/boolField.html' %} + {% include 'form/fileField.html' %} + {% include 'form/urlField.html' %} + {% include 'form/integerField.html' %} {% endif %} {% endfor %} diff --git a/web/minibase/templates/form/fileField.html b/web/minibase/templates/form/fileField.html new file mode 100644 index 00000000..2f9b8d0a --- /dev/null +++ b/web/minibase/templates/form/fileField.html @@ -0,0 +1,17 @@ +{% if item.type in ['FileField'] %} + {{ item.label(class=theme.form.file_label_class, style=theme.form.file_label_style) }} +
+{% endif %} +{% if item.errors %} + {{ item(class=theme.form.input_error_class) }} +
+ {% for error in item.errors %} + {{ error }} + {% endfor %} +
+{% else %} + {% if item.type in ['FileField'] %} + {{ item(class=theme.form.file_class, type=theme.form.file_type, style=theme.form.file_style) }} +
+ {% endif %} +{% endif %} diff --git a/web/minibase/templates/form/selectFieldHor.html b/web/minibase/templates/form/selectFieldHor.html index e3f2590c..cb5b4518 100644 --- a/web/minibase/templates/form/selectFieldHor.html +++ b/web/minibase/templates/form/selectFieldHor.html @@ -1,5 +1,5 @@ {% if item.type in ['SelectField'] %} - {{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }} + {{ item.label(class=theme.form.select_label_class, style=theme.form.select_label_style) }} {% endif %} {% if item.errors %} {{ item(class=theme.form.input_error_class) }} @@ -9,7 +9,9 @@ {% endfor %} {% else %} +
{% if item.type in ['SelectField'] %} {{ item(class=theme.form.select_class, type=theme.form.select_type, style=theme.form.select_style) }} {% endif %} +
{% endif %} diff --git a/web/minibase/templates/form/selectFieldVer.html b/web/minibase/templates/form/selectFieldVer.html index fd8227e4..98e19d63 100644 --- a/web/minibase/templates/form/selectFieldVer.html +++ b/web/minibase/templates/form/selectFieldVer.html @@ -1,10 +1,10 @@ {% if item.type in ['SelectField'] %} - {{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }} + {{ item.label(class=theme.form.select_label_class, style=theme.form.select_label_style) }}
{% endif %} {% if item.errors %} {{ item(class=theme.form.input_error_class) }} -
+
{% for error in item.errors %} {{ error }} {% endfor %} diff --git a/web/minibase/templates/form/stringField.html b/web/minibase/templates/form/stringField.html index 060fd3a7..1d49b41e 100644 --- a/web/minibase/templates/form/stringField.html +++ b/web/minibase/templates/form/stringField.html @@ -10,6 +10,8 @@
{% else %} {% if item.type in ['StringField', 'TextAreaField', 'PasswordField'] %} +
{{ item(class=theme.form.input_class) }} +
{% endif %} {% endif %} diff --git a/web/minibase/templates/form/urlField.html b/web/minibase/templates/form/urlField.html new file mode 100644 index 00000000..b673b063 --- /dev/null +++ b/web/minibase/templates/form/urlField.html @@ -0,0 +1,15 @@ +{% if item.type in ['URLField'] %} + {{ item.label(class=theme.form.url_label_class, style=theme.form.url_label_style) }} +{% endif %} +{% if item.errors %} + {{ item(class=theme.form.url_error_class) }} +
+ {% for error in item.errors %} + {{ error }} + {% endfor %} +
+{% else %} + {% if item.type in ['URLField'] %} + {{ item(class=theme.form.url_class, type=theme.form.url_type, style=theme.form.url_style) }} + {% endif %} +{% endif %} diff --git a/web/minibase/theme.py b/web/minibase/theme.py index d3e0fc0e..77f36965 100644 --- a/web/minibase/theme.py +++ b/web/minibase/theme.py @@ -17,23 +17,46 @@ class form: div_style = "background-color:" + black + "; " +" width:98%;" div_class = "container rounded p-4 py-4" div_error_class = "invalid-feedback" + + default_label_class = "col-form-label" + default_label_style = "color:" + orange + "; font-size: 14pt; font-weight: bold;" + default_error_class = "form-control form-control-lg is-invalid" - input_label_class = "col-form-label" - input_label_style = "color:" + orange + "; font-size: 14pt; font-weight: bold;" + input_label_class = default_label_class + input_label_style = default_label_style input_class = "form-control form-control-lg" - input_error_class = input_class+ " is-invalid" + input_error_class = default_error_class check_label_class = "form-check-label" check_label_style = "input_label_style" check_class = "form-check-input" + file_label_class = default_label_class + file_label_style = default_label_style + file_class = input_class + file_type = "file" + file_error_class = default_error_class + + url_label_class = default_label_class + url_label_style = default_label_style + url_class = input_class + url_default = "https://example.com/" + url_error_class = default_error_class + + select_label_class = default_label_class + select_label_style = default_label_style + select_class = "btn btn-lg form-select" + select_style = "color:" + black + "; font-size: 14pt; background-color: " + white + ";" + submit_class = "btn btn-outline-info mb-2 mt-2" - submit_style = "" - + submit_style = "" + date_label_class = default_label_class + date_label_style = default_label_style + date_class = "" + date_error_class = default_error_class date_type = "date" - select_class = "btn btn-lg dropdown-toggle" - select_style = "color:" + black + "; font-size: 14pt; background-color: " + white + ";" + class menu: menuDict = generate_blueprint_structure('minibase/blueprints')