From 0ad03a3fb59877f08cebfccc25658dc22a042281 Mon Sep 17 00:00:00 2001 From: Anand Chitipothu Date: Thu, 6 May 2021 20:41:52 +0530 Subject: [PATCH] style: made the avatar and name of the person a link --- community/community/widgets/Avatar.html | 2 ++ community/lms/widgets/CourseTeaser.html | 4 +++- community/lms/widgets/SketchTeaser.html | 3 ++- community/widgets.py | 7 +++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/community/community/widgets/Avatar.html b/community/community/widgets/Avatar.html index 8158f3df..e0c88cf5 100644 --- a/community/community/widgets/Avatar.html +++ b/community/community/widgets/Avatar.html @@ -1,4 +1,5 @@ {% set color = member.get_palette() %} + {% if member.photo %} @@ -9,4 +10,5 @@ {{ member.abbr }} {% endif %} + diff --git a/community/lms/widgets/CourseTeaser.html b/community/lms/widgets/CourseTeaser.html index 525d94c1..029db9ae 100644 --- a/community/lms/widgets/CourseTeaser.html +++ b/community/lms/widgets/CourseTeaser.html @@ -7,7 +7,9 @@ diff --git a/community/lms/widgets/SketchTeaser.html b/community/lms/widgets/SketchTeaser.html index 6c8ec431..02f5f5d7 100644 --- a/community/lms/widgets/SketchTeaser.html +++ b/community/lms/widgets/SketchTeaser.html @@ -9,7 +9,8 @@ {{sketch.title}}
- by {{sketch.get_owner().full_name}} + {% set owner = sketch.get_owner() %} + by {{owner.full_name}}
diff --git a/community/widgets.py b/community/widgets.py index 1e135187..99ed1829 100644 --- a/community/widgets.py +++ b/community/widgets.py @@ -36,8 +36,9 @@ class Widgets: '
Hello, World!
' """ def __getattr__(self, name): + widget_globals = {"widgets": self} if not name.startswith("__"): - return Widget(name) + return Widget(name, widget_globals) else: raise AttributeError(name) @@ -51,11 +52,13 @@ class Widget: >>> w(name="World!") '
Hello, World!
' """ - def __init__(self, name): + def __init__(self, name, widget_globals={}): + self.widget_globals = widget_globals self.name = name def __call__(self, **kwargs): # the widget could be in any of the modules paths = [f"{module}/widgets/{self.name}.html" for module in MODULES] env = get_jenv() + kwargs.update(self.widget_globals) return env.get_or_select_template(paths).render(kwargs)