From aac08f66bad5e2d2488c9aeb6e38cd7e1f8a32ce Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 2 Jul 2022 17:15:12 +0200 Subject: add a "friends of tagged people" visibility --- fietsboek/locale/en/LC_MESSAGES/messages.mo | Bin 8594 -> 8731 bytes fietsboek/locale/en/LC_MESSAGES/messages.po | 71 +++++++++++++++------------- fietsboek/locale/fietslog.pot | 64 +++++++++++++------------ fietsboek/models/track.py | 11 +++++ fietsboek/templates/edit_form.jinja2 | 1 + 5 files changed, 83 insertions(+), 64 deletions(-) diff --git a/fietsboek/locale/en/LC_MESSAGES/messages.mo b/fietsboek/locale/en/LC_MESSAGES/messages.mo index a31f469..3343b6f 100644 Binary files a/fietsboek/locale/en/LC_MESSAGES/messages.mo and b/fietsboek/locale/en/LC_MESSAGES/messages.mo differ diff --git a/fietsboek/locale/en/LC_MESSAGES/messages.po b/fietsboek/locale/en/LC_MESSAGES/messages.po index a9ce00f..c402e05 100644 --- a/fietsboek/locale/en/LC_MESSAGES/messages.po +++ b/fietsboek/locale/en/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2022-07-02 00:40+0200\n" +"POT-Creation-Date: 2022-07-02 17:11+0200\n" "PO-Revision-Date: 2022-06-28 13:11+0200\n" "Last-Translator: \n" "Language: en\n" @@ -26,31 +26,31 @@ msgstr "Passwords don't match" msgid "password_constraint.length" msgstr "Password not long enough" -#: fietsboek/models/track.py:381 +#: fietsboek/models/track.py:392 msgid "tooltip.table.length" msgstr "Length" -#: fietsboek/models/track.py:382 +#: fietsboek/models/track.py:393 msgid "tooltip.table.uphill" msgstr "Uphill" -#: fietsboek/models/track.py:383 +#: fietsboek/models/track.py:394 msgid "tooltip.table.downhill" msgstr "Downhill" -#: fietsboek/models/track.py:384 +#: fietsboek/models/track.py:395 msgid "tooltip.table.moving_time" msgstr "Moving Time" -#: fietsboek/models/track.py:385 +#: fietsboek/models/track.py:396 msgid "tooltip.table.stopped_time" msgstr "Stopped Time" -#: fietsboek/models/track.py:386 +#: fietsboek/models/track.py:397 msgid "tooltip.table.max_speed" msgstr "Max Speed" -#: fietsboek/models/track.py:388 +#: fietsboek/models/track.py:399 msgid "tooltip.table.avg_speed" msgstr "Average Speed" @@ -130,39 +130,39 @@ msgstr "Average Speed" msgid "page.create_account.title" msgstr "Create Account" -#: fietsboek/templates/create_account.jinja2:7 -msgid "page.create_account.email" -msgstr "E-Mail" - #: fietsboek/templates/create_account.jinja2:11 msgid "page.create_account.email_invalid" msgstr "Invalid email address" -#: fietsboek/templates/create_account.jinja2:16 -msgid "page.create_account.name" -msgstr "Name" +#: fietsboek/templates/create_account.jinja2:13 +msgid "page.create_account.email" +msgstr "E-Mail" -#: fietsboek/templates/create_account.jinja2:20 +#: fietsboek/templates/create_account.jinja2:22 msgid "page.create_account.name_invalid" msgstr "Name invalid" -#: fietsboek/templates/create_account.jinja2:25 -msgid "page.create_account.password" -msgstr "Password" +#: fietsboek/templates/create_account.jinja2:24 +msgid "page.create_account.name" +msgstr "Name" -#: fietsboek/templates/create_account.jinja2:29 +#: fietsboek/templates/create_account.jinja2:33 msgid "page.create_account.password_invalid" msgstr "Password not long enough" -#: fietsboek/templates/create_account.jinja2:34 -msgid "page.create_account.repeat_password" -msgstr "Repeat password" +#: fietsboek/templates/create_account.jinja2:35 +msgid "page.create_account.password" +msgstr "Password" -#: fietsboek/templates/create_account.jinja2:38 +#: fietsboek/templates/create_account.jinja2:44 msgid "page.create_account.password_must_match" msgstr "Passwords must match" -#: fietsboek/templates/create_account.jinja2:42 +#: fietsboek/templates/create_account.jinja2:46 +msgid "page.create_account.repeat_password" +msgstr "Repeat password" + +#: fietsboek/templates/create_account.jinja2:52 msgid "page.create_account.create" msgstr "Create" @@ -264,40 +264,44 @@ msgid "page.track.form.visibility.friends" msgstr "Friends only" #: fietsboek/templates/edit_form.jinja2:15 +msgid "page.track.form.visibility.friends_tagged" +msgstr "Friends of all tagged people" + +#: fietsboek/templates/edit_form.jinja2:16 msgid "page.track.form.visibility.logged_in" msgstr "Logged in users" -#: fietsboek/templates/edit_form.jinja2:16 +#: fietsboek/templates/edit_form.jinja2:17 msgid "page.track.form.visibility.public" msgstr "Public" -#: fietsboek/templates/edit_form.jinja2:19 +#: fietsboek/templates/edit_form.jinja2:20 msgid "page.track.form.visibility.info" msgstr "" "Note that tagged people and people with the share link can always view " "the track." -#: fietsboek/templates/edit_form.jinja2:23 +#: fietsboek/templates/edit_form.jinja2:24 msgid "page.track.form.tags" msgstr "Tags" -#: fietsboek/templates/edit_form.jinja2:34 +#: fietsboek/templates/edit_form.jinja2:35 msgid "page.track.form.add_tag" msgstr "Add Tag" -#: fietsboek/templates/edit_form.jinja2:39 +#: fietsboek/templates/edit_form.jinja2:40 msgid "page.track.form.tagged_people" msgstr "Tagged People" -#: fietsboek/templates/edit_form.jinja2:54 +#: fietsboek/templates/edit_form.jinja2:55 msgid "page.track.form.add_friend" msgstr "Search friends" -#: fietsboek/templates/edit_form.jinja2:74 +#: fietsboek/templates/edit_form.jinja2:75 msgid "page.track.form.badges" msgstr "Badges" -#: fietsboek/templates/edit_form.jinja2:85 +#: fietsboek/templates/edit_form.jinja2:86 msgid "page.track.form.description" msgstr "Description" @@ -482,7 +486,6 @@ msgid "flash.invalid_name" msgstr "Invalid name" #: fietsboek/views/account.py:53 -#, fuzzy msgid "flash.invalid_email" msgstr "Invalid email" diff --git a/fietsboek/locale/fietslog.pot b/fietsboek/locale/fietslog.pot index b779e12..8e00bf3 100644 --- a/fietsboek/locale/fietslog.pot +++ b/fietsboek/locale/fietslog.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2022-07-02 00:40+0200\n" +"POT-Creation-Date: 2022-07-02 17:11+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -25,31 +25,31 @@ msgstr "" msgid "password_constraint.length" msgstr "" -#: fietsboek/models/track.py:381 +#: fietsboek/models/track.py:392 msgid "tooltip.table.length" msgstr "" -#: fietsboek/models/track.py:382 +#: fietsboek/models/track.py:393 msgid "tooltip.table.uphill" msgstr "" -#: fietsboek/models/track.py:383 +#: fietsboek/models/track.py:394 msgid "tooltip.table.downhill" msgstr "" -#: fietsboek/models/track.py:384 +#: fietsboek/models/track.py:395 msgid "tooltip.table.moving_time" msgstr "" -#: fietsboek/models/track.py:385 +#: fietsboek/models/track.py:396 msgid "tooltip.table.stopped_time" msgstr "" -#: fietsboek/models/track.py:386 +#: fietsboek/models/track.py:397 msgid "tooltip.table.max_speed" msgstr "" -#: fietsboek/models/track.py:388 +#: fietsboek/models/track.py:399 msgid "tooltip.table.avg_speed" msgstr "" @@ -129,39 +129,39 @@ msgstr "" msgid "page.create_account.title" msgstr "" -#: fietsboek/templates/create_account.jinja2:7 -msgid "page.create_account.email" -msgstr "" - #: fietsboek/templates/create_account.jinja2:11 msgid "page.create_account.email_invalid" msgstr "" -#: fietsboek/templates/create_account.jinja2:16 -msgid "page.create_account.name" +#: fietsboek/templates/create_account.jinja2:13 +msgid "page.create_account.email" msgstr "" -#: fietsboek/templates/create_account.jinja2:20 +#: fietsboek/templates/create_account.jinja2:22 msgid "page.create_account.name_invalid" msgstr "" -#: fietsboek/templates/create_account.jinja2:25 -msgid "page.create_account.password" +#: fietsboek/templates/create_account.jinja2:24 +msgid "page.create_account.name" msgstr "" -#: fietsboek/templates/create_account.jinja2:29 +#: fietsboek/templates/create_account.jinja2:33 msgid "page.create_account.password_invalid" msgstr "" -#: fietsboek/templates/create_account.jinja2:34 -msgid "page.create_account.repeat_password" +#: fietsboek/templates/create_account.jinja2:35 +msgid "page.create_account.password" msgstr "" -#: fietsboek/templates/create_account.jinja2:38 +#: fietsboek/templates/create_account.jinja2:44 msgid "page.create_account.password_must_match" msgstr "" -#: fietsboek/templates/create_account.jinja2:42 +#: fietsboek/templates/create_account.jinja2:46 +msgid "page.create_account.repeat_password" +msgstr "" + +#: fietsboek/templates/create_account.jinja2:52 msgid "page.create_account.create" msgstr "" @@ -263,38 +263,42 @@ msgid "page.track.form.visibility.friends" msgstr "" #: fietsboek/templates/edit_form.jinja2:15 -msgid "page.track.form.visibility.logged_in" +msgid "page.track.form.visibility.friends_tagged" msgstr "" #: fietsboek/templates/edit_form.jinja2:16 +msgid "page.track.form.visibility.logged_in" +msgstr "" + +#: fietsboek/templates/edit_form.jinja2:17 msgid "page.track.form.visibility.public" msgstr "" -#: fietsboek/templates/edit_form.jinja2:19 +#: fietsboek/templates/edit_form.jinja2:20 msgid "page.track.form.visibility.info" msgstr "" -#: fietsboek/templates/edit_form.jinja2:23 +#: fietsboek/templates/edit_form.jinja2:24 msgid "page.track.form.tags" msgstr "" -#: fietsboek/templates/edit_form.jinja2:34 +#: fietsboek/templates/edit_form.jinja2:35 msgid "page.track.form.add_tag" msgstr "" -#: fietsboek/templates/edit_form.jinja2:39 +#: fietsboek/templates/edit_form.jinja2:40 msgid "page.track.form.tagged_people" msgstr "" -#: fietsboek/templates/edit_form.jinja2:54 +#: fietsboek/templates/edit_form.jinja2:55 msgid "page.track.form.add_friend" msgstr "" -#: fietsboek/templates/edit_form.jinja2:74 +#: fietsboek/templates/edit_form.jinja2:75 msgid "page.track.form.badges" msgstr "" -#: fietsboek/templates/edit_form.jinja2:85 +#: fietsboek/templates/edit_form.jinja2:86 msgid "page.track.form.description" msgstr "" diff --git a/fietsboek/models/track.py b/fietsboek/models/track.py index cc5283a..c8b8dc5 100644 --- a/fietsboek/models/track.py +++ b/fietsboek/models/track.py @@ -15,6 +15,8 @@ import enum import gzip import datetime +from itertools import chain + from sqlalchemy import ( Column, Integer, @@ -65,6 +67,8 @@ class Visibility(enum.Enum): """Only the owner of the track can see it.""" FRIENDS = enum.auto() """Friends of the owner can see the track as well.""" + FRIENDS_TAGGED = enum.auto() + """Friends of the owner or friends of tagged people can see the track.""" LOGGED_IN = enum.auto() """Any logged in user can see the track.""" PUBLIC = enum.auto() @@ -179,6 +183,13 @@ class Track(Base): # logged in user is a friend. if self.visibility == Visibility.FRIENDS: return user in self.owner.get_friends() + if self.visibility == Visibility.FRIENDS_TAGGED: + all_friends = { + friend + for person in chain([self.owner], self.tagged_people) + for friend in person.get_friends() + } + return user in all_friends if user and self.visibility == Visibility.LOGGED_IN: return True return False diff --git a/fietsboek/templates/edit_form.jinja2 b/fietsboek/templates/edit_form.jinja2 index 5851673..6078264 100644 --- a/fietsboek/templates/edit_form.jinja2 +++ b/fietsboek/templates/edit_form.jinja2 @@ -12,6 +12,7 @@ -- cgit v1.2.3