Skip to content

Commit

Permalink
Merge pull request #19 from NatLibFi/dev
Browse files Browse the repository at this point in the history
Dev->main, municipality validation
  • Loading branch information
natlibfi-psams authored Aug 30, 2024
2 parents 558eebd + 6d5d4a4 commit 0682fdd
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build

on:
push:
branches: ["*"]
branches: ["dev"]
pull_request:
branches: ["main"]
release:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ If you change the municipalities emails csv file remember to restart the server

Create a virtual environment with something like
`python -m venv venv`
activate it
`. ./venv/bin/activate`
then install dependencies with
`pip install -r requirements.txt`.
and run the app with
Expand Down
9 changes: 7 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
SelectField,
SubmitField,
validators,
ValidationError
)

from flask_babel import lazy_gettext as _
Expand Down Expand Up @@ -47,6 +48,9 @@ def get_locale():
csrf = CSRFProtect(app)
app.secret_key = secrets.token_urlsafe(16)

def validate_municipality(form, field):
if field.data == "":
raise ValidationError(_("Please select a valid municipality."))

class FeedbackForm(FlaskForm):
subject = SelectField(
Expand All @@ -71,14 +75,16 @@ class FeedbackForm(FlaskForm):
_("Message"),
[validators.DataRequired(), validators.Length(1, 2048)],
)

municipality = SelectField(
_("My home municipality that receives this feedback"),
choices=indexed_municipalities(),
choices=[("", _("Select a municipality"))] + indexed_municipalities(),
render_kw={
"class": "form-select",
"data-control": "select2",
"data-dropdown-parent": "body",
},
validators=[validate_municipality]
)
email = EmailField(
_("Email address, if you want an answer to your feedback (Optional)"),
Expand All @@ -88,7 +94,6 @@ class FeedbackForm(FlaskForm):
_("Send"),
)


@app.route(root_path, methods=["GET", "POST"])
def feedback(name=None):
form = FeedbackForm()
Expand Down
36 changes: 18 additions & 18 deletions messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-06-04 16:08+0300\n"
"POT-Creation-Date: 2024-08-23 09:07+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -17,6 +17,10 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.14.0\n"

#: app.py:53
msgid "Please select a valid municipality."
msgstr ""

#: app.py:57
msgid "Subject"
msgstr ""
Expand Down Expand Up @@ -69,49 +73,45 @@ msgstr ""
msgid "Message"
msgstr ""

#: app.py:79
#: app.py:81
msgid "My home municipality that receives this feedback"
msgstr ""

#: app.py:88
#: app.py:82
msgid "Select a municipality"
msgstr ""

#: app.py:91
msgid "Email address, if you want an answer to your feedback (Optional)"
msgstr ""

#: app.py:92
#: app.py:95
msgid "Send"
msgstr ""

#: app.py:138
#: app.py:144
msgid "English"
msgstr ""

#: app.py:139
#: app.py:145
msgid "Finnish"
msgstr ""

#: app.py:140
#: app.py:146
msgid "Swedish"
msgstr ""

#: app.py:149
#: app.py:155
msgid ""
"You can leave feedback about the E-library or suggest materials for "
"acquisition. Suggestions for materials will not be responded to."
msgstr ""

#: app.py:219
#: app.py:226
msgid "Thank you for your feedback!"
msgstr ""

#: app.py:225
#: app.py:232
msgid "There was a problem sending your message."
msgstr ""

#: municipalities.py:51
msgid "My home municipality is missing from this list"
msgstr ""

#: municipalities.py:54
msgid "I don't want to say"
msgstr ""

Binary file modified translations/en/LC_MESSAGES/messages.mo
Binary file not shown.
40 changes: 23 additions & 17 deletions translations/en/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-06-04 16:08+0300\n"
"POT-Creation-Date: 2024-08-23 09:07+0300\n"
"PO-Revision-Date: 2024-04-16 17:50+0300\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
Expand All @@ -18,6 +18,10 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.14.0\n"

#: app.py:53
msgid "Please select a valid municipality."
msgstr ""

#: app.py:57
msgid "Subject"
msgstr ""
Expand Down Expand Up @@ -70,52 +74,54 @@ msgstr ""
msgid "Message"
msgstr ""

#: app.py:79
#: app.py:81
msgid "My home municipality that receives this feedback"
msgstr ""

#: app.py:88
#: app.py:82
msgid "Select a municipality"
msgstr ""

#: app.py:91
msgid "Email address, if you want an answer to your feedback (Optional)"
msgstr ""

#: app.py:92
#: app.py:95
msgid "Send"
msgstr ""

#: app.py:138
#: app.py:144
msgid "English"
msgstr ""

#: app.py:139
#: app.py:145
msgid "Finnish"
msgstr "Suomi"

#: app.py:140
#: app.py:146
msgid "Swedish"
msgstr "Svenska"

#: app.py:149
#: app.py:155
msgid ""
"You can leave feedback about the E-library or suggest materials for "
"acquisition. Suggestions for materials will not be responded to."
msgstr ""

#: app.py:219
#: app.py:226
msgid "Thank you for your feedback!"
msgstr ""

#: app.py:225
#: app.py:232
msgid "There was a problem sending your message."
msgstr ""

#: municipalities.py:51
msgid "My home municipality is missing from this list"
msgstr ""
#~ msgid "Software version"
#~ msgstr ""

#: municipalities.py:54
msgid "I don't want to say"
msgstr ""
#~ msgid "My home municipality is missing from this list"
#~ msgstr ""

#~ msgid "Software version"
#~ msgid "I don't want to say"
#~ msgstr ""

Binary file modified translations/fi/LC_MESSAGES/messages.mo
Binary file not shown.
42 changes: 24 additions & 18 deletions translations/fi/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-06-04 16:08+0300\n"
"POT-Creation-Date: 2024-08-23 09:07+0300\n"
"PO-Revision-Date: 2024-04-16 16:30+0300\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fi\n"
Expand All @@ -18,6 +18,10 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.14.0\n"

#: app.py:53
msgid "Please select a valid municipality."
msgstr "Valinta on pakollinen."

#: app.py:57
msgid "Subject"
msgstr "Aihe"
Expand Down Expand Up @@ -70,54 +74,56 @@ msgstr "Kirjan nimi"
msgid "Message"
msgstr "Viesti"

#: app.py:79
#: app.py:81
msgid "My home municipality that receives this feedback"
msgstr "Kotikuntani, jolle palaute osoitetaan"

#: app.py:88
#: app.py:82
msgid "Select a municipality"
msgstr "Valitse kotikunta"

#: app.py:91
msgid "Email address, if you want an answer to your feedback (Optional)"
msgstr "Sähköpostiosoite, johon haluat vastauksen palautteellesi (Valinnainen)"

#: app.py:92
#: app.py:95
msgid "Send"
msgstr "Lähetä"

#: app.py:138
#: app.py:144
msgid "English"
msgstr "English "

#: app.py:139
#: app.py:145
msgid "Finnish"
msgstr "Suomi "

#: app.py:140
#: app.py:146
msgid "Swedish"
msgstr "Svenska "

#: app.py:149
#: app.py:155
msgid ""
"You can leave feedback about the E-library or suggest materials for "
"acquisition. Suggestions for materials will not be responded to."
msgstr ""
"Voit jättää palautetta E-kirjastosta tai ehdottaa hankittavia aineistoja."
" Aineistoehdotuksiin ei vastata."

#: app.py:219
#: app.py:226
msgid "Thank you for your feedback!"
msgstr "Kiitos palautteesta!"

#: app.py:225
#: app.py:232
msgid "There was a problem sending your message."
msgstr "Viestin lähetyksessä tapahtui virhe."

#: municipalities.py:51
msgid "My home municipality is missing from this list"
msgstr "Kotikuntani puuttuu tästä listasta"

#: municipalities.py:54
msgid "I don't want to say"
msgstr "En halua kertoa"

#~ msgid "Software version"
#~ msgstr ""

#~ msgid "My home municipality is missing from this list"
#~ msgstr "Kotikuntani puuttuu tästä listasta"

#~ msgid "I don't want to say"
#~ msgstr "En halua kertoa"

Binary file modified translations/sv/LC_MESSAGES/messages.mo
Binary file not shown.
Loading

0 comments on commit 0682fdd

Please sign in to comment.