From c0c38ccb523506888078d4486c64eaa2d20384f0 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 25 Jul 2018 08:24:10 +0200 Subject: [PATCH] Make it possible to use builtin avatars Images are from openclipart.org --- calsocial/__init__.py | 10 +++ calsocial/models.py | 3 + calsocial/static/avatars/doctor.svg | 35 +++++++++ calsocial/static/avatars/engineer.svg | 54 ++++++++++++++ calsocial/static/avatars/scientist.svg | 91 +++++++++++++++++++++++ calsocial/static/avatars/statistician.svg | 39 ++++++++++ calsocial/static/avatars/user.svg | 11 +++ calsocial/static/avatars/whoami.svg | 26 +++++++ calsocial/templates/profile-details.html | 7 +- 9 files changed, 274 insertions(+), 2 deletions(-) create mode 100644 calsocial/static/avatars/doctor.svg create mode 100644 calsocial/static/avatars/engineer.svg create mode 100644 calsocial/static/avatars/scientist.svg create mode 100644 calsocial/static/avatars/statistician.svg create mode 100644 calsocial/static/avatars/user.svg create mode 100644 calsocial/static/avatars/whoami.svg diff --git a/calsocial/__init__.py b/calsocial/__init__.py index a4e105c..d03e802 100644 --- a/calsocial/__init__.py +++ b/calsocial/__init__.py @@ -78,6 +78,16 @@ class CalendarSocialApp(Flask, RoutedMixin): self.config['SECURITY_USER_IDENTITY_ATTRIBUTES'] = ('username', 'email') self.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'login.html' + # The builtin avatars to use + self.config['BUILTIN_AVATARS'] = ( + 'doctor', + 'engineer', + 'scientist', + 'statistician', + 'user', + 'whoami', + ) + self.jinja_env.policies['ext.i18n.trimmed'] = True # pylint: disable=no-member db.init_app(self) diff --git a/calsocial/models.py b/calsocial/models.py index 61fde67..b0c4dff 100644 --- a/calsocial/models.py +++ b/calsocial/models.py @@ -285,6 +285,9 @@ class Profile(db.Model): # pylint: disable=too-few-public-methods #: If locked, a profile cannot be followed without the owner’s consent locked = db.Column(db.Boolean(), default=False) + #: If set, the profile will display this builtin avatar + builtin_avatar = db.Column(db.String(length=40), nullable=True) + @property def fqn(self): """The fully qualified name of the profile diff --git a/calsocial/static/avatars/doctor.svg b/calsocial/static/avatars/doctor.svg new file mode 100644 index 0000000..48acf64 --- /dev/null +++ b/calsocial/static/avatars/doctor.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +image/svg+xmlOpenclipartUsers2007-11-16T10:54:09https://openclipart.org/detail/11056/users-by-sampler-11056samplerjobpeopleprofessionuserwork \ No newline at end of file diff --git a/calsocial/static/avatars/engineer.svg b/calsocial/static/avatars/engineer.svg new file mode 100644 index 0000000..eedfe90 --- /dev/null +++ b/calsocial/static/avatars/engineer.svg @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +image/svg+xmlOpenclipartUsers2007-11-16T10:54:09https://openclipart.org/detail/11060/users-by-sampler-11060samplerjobpeopleprofessionuserwork \ No newline at end of file diff --git a/calsocial/static/avatars/scientist.svg b/calsocial/static/avatars/scientist.svg new file mode 100644 index 0000000..564855b --- /dev/null +++ b/calsocial/static/avatars/scientist.svg @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +image/svg+xmlOpenclipartUsers2007-11-16T10:54:09https://openclipart.org/detail/11064/users-by-sampler-11064samplerjobpeopleprofessionuserwork \ No newline at end of file diff --git a/calsocial/static/avatars/statistician.svg b/calsocial/static/avatars/statistician.svg new file mode 100644 index 0000000..26bb043 --- /dev/null +++ b/calsocial/static/avatars/statistician.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +image/svg+xmlOpenclipartUsers2007-11-16T10:54:09https://openclipart.org/detail/11065/users-by-sampler-11065samplerjobpeopleprofessionuserwork \ No newline at end of file diff --git a/calsocial/static/avatars/user.svg b/calsocial/static/avatars/user.svg new file mode 100644 index 0000000..5956a5b --- /dev/null +++ b/calsocial/static/avatars/user.svg @@ -0,0 +1,11 @@ + + + + + + + + +image/svg+xmlOpenclipartUsers2007-11-16T10:54:09https://openclipart.org/detail/11055/users-by-sampler-11055samplerjobpeopleprofessionuserwork \ No newline at end of file diff --git a/calsocial/static/avatars/whoami.svg b/calsocial/static/avatars/whoami.svg new file mode 100644 index 0000000..c0ac8f9 --- /dev/null +++ b/calsocial/static/avatars/whoami.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + +image/svg+xmlOpenclipartUsers2007-11-16T10:54:09https://openclipart.org/detail/11063/users-by-sampler-11063samplerjobpeopleprofessionuserwork \ No newline at end of file diff --git a/calsocial/templates/profile-details.html b/calsocial/templates/profile-details.html index 7c1fe51..cf75d74 100644 --- a/calsocial/templates/profile-details.html +++ b/calsocial/templates/profile-details.html @@ -1,14 +1,17 @@ {% extends 'base.html' %} {% block content %} -

+

+ {% if profile.builtin_avatar %} + + {% endif %} {% if profile.locked %} {% trans %}locked profile{% endtrans %} {% endif %} {{ profile.display_name }} @{{ profile.user.username}} -

+ {% if profile.user != current_user %} {% trans %}Follow{% endtrans %} {% endif %}