Skip to content

Commit

Permalink
Merge branch 'bugfix/BB-20459-style-email' into bugfix/BB-20448-join-…
Browse files Browse the repository at this point in the history
…team-mails
  • Loading branch information
gannetson committed Aug 17, 2022
2 parents 7e6efb4 + e6884eb commit 21e02cf
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 10 deletions.
4 changes: 4 additions & 0 deletions bluebottle/time_based/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ class ReminderTeamSlotNotification(TransitionMessage):
'start': 'start',
'duration': 'duration',
'end': 'end',
'timezone': 'timezone',
'location': 'location',
}

def already_send(self, recipient):
Expand Down Expand Up @@ -281,6 +283,8 @@ class TeamSlotChangedNotification(TransitionMessage):
'start': 'start',
'duration': 'duration',
'end': 'end',
'timezone': 'timezone',
'location': 'location',
}

@property
Expand Down
5 changes: 5 additions & 0 deletions bluebottle/time_based/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,11 @@ def end(self):
if self.start and self.duration:
return self.start + self.duration

@property
def timezone(self):
if self.start:
return self.start.strftime("%Z %z")

@property
def is_complete(self):
return self.start and self.duration
Expand Down
3 changes: 3 additions & 0 deletions bluebottle/time_based/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class TimeBasedBaseSerializer(BaseActivitySerializer):
review = serializers.BooleanField(required=False)
is_online = serializers.BooleanField(required=False, allow_null=True)

teams = TeamsField()

class Meta(BaseActivitySerializer.Meta):
fields = BaseActivitySerializer.Meta.fields + (
'capacity',
Expand All @@ -55,6 +57,7 @@ class Meta(BaseActivitySerializer.Meta):
'review',
'contributors',
'my_contributor',
'teams',
)

class JSONAPIMeta(BaseActivitySerializer.JSONAPIMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
Some details of the team activity you are a part of have changed:
{% endblocktrans %}
</p>
<p>
{% blocktrans context 'email' %}
Updated details below:
{% endblocktrans %}
</p>
<p>
{{ team_name }}
</p>
<p>
{{ title }}
"{{ title }}"
</p>

{% if duration %}
{% include 'mails/messages/partial/period.html' %}
{% else %}
{% include 'mails/messages/partial/slots.html' %}
{% endif %}
</p>
{% include 'mails/messages/partial/team_slot.html' %}

<p>
{% blocktrans context 'email' %}
Please view your team from the activity page to see the changes.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% load i18n tz %}
<p>
{% trans 'Date' %}: {{ start|date:"SHORT_DATE_FORMAT" }}
</p>
<p>
{% trans 'Time' %}: {{ start|date:'TIME_FORMAT' }} - {{ end|date:'TIME_FORMAT' }} {{ timezone }}
</p>
{% if location %}
<p>
{% trans 'Location' %}: {{ location }} {{ location_hint }}
</p>
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{ title }}
</p>
<p>
{% include 'mails/messages/partial/period.html' %}
{% include 'mails/messages/partial/team_slot.html' %}
</p>

<p>
Expand Down
4 changes: 2 additions & 2 deletions bluebottle/time_based/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ def has_accepted_invite(effect):


def is_not_team_activity(effect):
"""Contributor is not part of a team"""
"""Activity is not for teams"""
return effect.instance.activity.team_activity != 'teams'


Expand Down Expand Up @@ -1313,8 +1313,8 @@ class ParticipantTriggers(ContributorTriggers):
NotificationEffect(
TeamMemberAddedMessage,
conditions=[
is_team_activity,
not_team_captain,
has_team
]
),
NotificationEffect(
Expand Down
3 changes: 3 additions & 0 deletions scripts/generate_notifications_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ def run(*args):
data = response.json()
version = data['version']['number'] + 1
html = ''
total = 0

for model in models:
model_class = import_string(model['model'])
messages = document_notifications(model_class)
if len(messages):
total += len(messages)
html += "<h2>{}</h2>".format(model_class._meta.verbose_name)
html += generate_notification_html(messages)

Expand All @@ -101,5 +103,6 @@ def run(*args):
response = requests.put(url, json=data, auth=(api['user'], api['key']))
if response.status_code == 200:
print("[OK]")
print(f"{total} messages")
else:
print("[ERROR]")

0 comments on commit 21e02cf

Please sign in to comment.