Skip to content

Commit

Permalink
Change account/project separator from > to / (resolves #1522) (#1526
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jace authored Nov 16, 2022
1 parent 3dec874 commit acfcbee
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 65 deletions.
29 changes: 20 additions & 9 deletions funnel/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,22 +526,33 @@ def title_suffix(self) -> str:

with_roles(title_suffix, read={'all'})

@with_roles(call={'all'})
def joined_title(self, sep: str = '›') -> str:
"""Return the project's title joined with the account's title, if divergent."""
@property
def title_parts(self) -> List[str]:
"""
Return the hierarchy of titles of this project.
If the project's title is an extension of the account's title, only the
project's title is returned as a single list item. If they are distinct, both
are returned.
This list is used by :prop:`joined_title` to produce a slash-separated title,
but can be used directly when another rendering is required.
"""
if self.short_title == self.title:
# Project title does not derive from account title, so use both
return f"{self.profile.title} {sep} {self.title}"
return [self.profile.title, self.title]
# Project title extends account title, so account title is not needed
return self.title
return [self.title]

with_roles(title_parts, read={'all'})

@property
def full_title(self) -> str:
"""Return :meth:`joined_title` as a property."""
return self.joined_title()
def joined_title(self) -> str:
"""Return the project's title joined with the account's title, if divergent."""
return ' / '.join(self.title_parts)

with_roles(
full_title, read={'all'}, datasets={'primary', 'without_parent', 'related'}
joined_title, read={'all'}, datasets={'primary', 'without_parent', 'related'}
)

@with_roles(read={'all'}, datasets={'primary', 'without_parent', 'related'})
Expand Down
10 changes: 0 additions & 10 deletions funnel/templates/macros.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
<input id="csrf_token" name="csrf_token" type="hidden" value="{{ csrf_token() }}"/>
{%- endmacro %}

{% macro project_title(project) %}
{%- if project.short_title == project.title -%}
{# Project title is not an extension of account title, so display account title too -#}
{{ project.profile.title }} › {{ project.title }}
{%- else -%}
{# Project title derives from account title, so account is not needed. -#}
{{ project.title }}
{%- endif %}
{%- endmacro %}

{% macro calendarwidget(calendar, compact=true) %}
<div class="card__calendar {% if compact %} card__calendar--compact {% endif %}" aria-hidden="true">
<div class="calendar">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{%- extends "notifications/layout_email.html.jinja2" -%}
{%- from "macros.html.jinja2" import project_title -%}
{%- block content -%}

{%- if view.notification.document_type == 'project' -%}
<h2><a href="{{ view.document.url_for(_external=true, **view.tracking_tags()) }}">{{ project_title(view.document) }}</a></h2>
<h2><a href="{{ view.document.url_for(_external=true, **view.tracking_tags()) }}">{{ view.document.joined_title }}</a></h2>
{%- elif view.notification.document_type == 'proposal' -%}
<h2><a href="{{ view.document.url_for(_external=true, **view.tracking_tags()) }}">{{ view.document.title }}</a></h2>
{%- elif view.notification.document_type == 'comment' -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{%- extends "notifications/layout_email.html.jinja2" -%}
{%- from "macros.html.jinja2" import project_title -%}
{%- from "notifications/macros_email.html.jinja2" import pinned_update -%}
{%- block content -%}

<p>
{%- trans project=project_title(view.project), start_time=view.session.start_at_localized|time -%}
{%- trans project=view.project.joined_title, start_time=view.session.start_at_localized|time -%}
<b>{{ project }}</b> starts at {{ start_time }}
{%- endtrans -%}
</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% extends "notifications/layout_web.html.jinja2" %}
{%- from "macros.html.jinja2" import project_title, useravatar %}
{%- from "macros.html.jinja2" import useravatar %}

{%- block avatar %}
{{ useravatar(view.project.profile.owner) }}
{%- endblock avatar -%}

{%- block content -%}
<p>
{% trans project=project_title(view.project), url=view.project.url_for(), start_time=view.session.start_at_localized|time -%}
{% trans project=view.project.joined_title, url=view.project.url_for(), start_time=view.session.start_at_localized|time -%}
<a href="{{ url }}">{{ project }}</a> starts at {{ start_time }}
{%- endtrans %}
</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% extends "notifications/layout_email.html.jinja2" %}
{%- from "macros.html.jinja2" import project_title %}
{% block content -%}

<p>{% trans project=project_title(project), proposal=proposal.title %}Your project <b>{{ project }}</b> has a new submission: <b>{{ proposal }}</b>{% endtrans %}</p>
<p>{% trans project=project.joined_title, proposal=proposal.title %}Your project <b>{{ project }}</b> has a new submission: <b>{{ proposal }}</b>{% endtrans %}</p>

<p class="btn-bar"><a class="btn" href="{{ proposal.url_for(_external=true, **view.tracking_tags()) }}">{% trans %}Submission page{% endtrans %}</a></p>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% extends "notifications/layout_web.html.jinja2" %}
{%- from "macros.html.jinja2" import faicon, project_title %}
{%- from "macros.html.jinja2" import faicon %}

{% block content %}
{%- if view.is_rollup %}
<p>
{%- trans project=project_title(project), project_url=project.url_for(), count=view.fragments|length %}
{%- trans project=project.joined_title, project_url=project.url_for(), count=view.fragments|length %}
Your project <a href="{{ project_url }}">{{ project }}</a> has received {{ count }} new submissions:
{%- endtrans %}
</p>
Expand All @@ -18,7 +18,7 @@
</ol>
{%- else %}
<p>
{% trans project=project_title(project), project_url=project.url_for(), proposal=proposal.title, proposal_url=proposal.url_for(), actor=view.actor.pickername -%}
{% trans project=project.joined_title, project_url=project.url_for(), proposal=proposal.title, proposal_url=proposal.url_for(), actor=view.actor.pickername -%}
Your project <a href="{{ project_url }}">{{ project }}</a> has received a new submission: <a href="{{ proposal_url }}">{{ proposal }}</a> from {{ actor }}
{%- endtrans %}
</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{% extends "notifications/layout_email.html.jinja2" %}
{%- from "macros.html.jinja2" import project_title %}
{% block content -%}

<p>{% trans project=project_title(project), proposal=proposal.title %}You have submitted a new proposal <b>{{ proposal }}</b> to the project <b>{{ project }}</b>{% endtrans %}</p>
<p>{% trans project=project.joined_title, proposal=proposal.title %}You have submitted <b>{{ proposal }}</b> to the project <b>{{ project }}</b>{% endtrans %}</p>

<p class="btn-bar"><a class="btn" href="{{ proposal.url_for(_external=true, **view.tracking_tags()) }}">{% trans %}View proposal{% endtrans %}</a></p>
<p class="btn-bar"><a class="btn" href="{{ proposal.url_for(_external=true, **view.tracking_tags()) }}">{% trans %}View submission{% endtrans %}</a></p>

{%- endblock content %}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% extends "notifications/layout_web.html.jinja2" %}
{%- from "macros.html.jinja2" import project_title %}
{% block content %}
<p>
{% trans project=project_title(project), project_url=project.url_for(), proposal=proposal.title, proposal_url=proposal.url_for() -%}
{% trans project=project.joined_title, project_url=project.url_for(), proposal=proposal.title, proposal_url=proposal.url_for() -%}
You submitted <a href="{{ proposal_url }}">{{ proposal }}</a> to <a href="{{ project_url }}">{{ project }}</a>
{%- endtrans %}
</p>
Expand Down
3 changes: 1 addition & 2 deletions funnel/templates/notifications/rsvp_no_email.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% extends "notifications/layout_email.html.jinja2" %}
{%- from "macros.html.jinja2" import project_title %}
{% block content -%}

<p>{% trans project=project_title(view.rsvp.project) %}You have cancelled your registration for <b>{{ project }}</b>. If this was accidental, you can register again.{% endtrans %}</p>
<p>{% trans project=view.rsvp.project.joined_title %}You have cancelled your registration for <b>{{ project }}</b>. If this was accidental, you can register again.{% endtrans %}</p>

<p class="btn-bar"><a class="btn" href="{{ view.rsvp.project.url_for(_external=true, **view.tracking_tags()) }}">{% trans %}Project page{% endtrans %}</a></p>

Expand Down
3 changes: 1 addition & 2 deletions funnel/templates/notifications/rsvp_no_web.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% extends "notifications/layout_web.html.jinja2" %}
{%- from "macros.html.jinja2" import project_title %}
{% block content %}
<p>
{% trans project=project_title(view.rsvp.project), url=view.rsvp.project.url_for() -%}
{% trans project=view.rsvp.project.joined_title, url=view.rsvp.project.url_for() -%}
You cancelled your registration for <a href="{{ url }}">{{ project }}</a>
{%- endtrans %}
</p>
Expand Down
3 changes: 1 addition & 2 deletions funnel/templates/notifications/rsvp_yes_email.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{% extends "notifications/layout_email.html.jinja2" -%}
{%- from "macros.html.jinja2" import project_title -%}
{%- from "notifications/macros_email.html.jinja2" import pinned_update -%}
{%- block content -%}

<p>{% trans project=project_title(view.rsvp.project) %}You have registered for <b>{{ project }}</b>{% endtrans %}</p>
<p>{% trans project=view.rsvp.project.joined_title %}You have registered for <b>{{ project }}</b>{% endtrans %}</p>

{% with next_session_at=view.rsvp.project.next_session_at %}{% if next_session_at -%}
<p>{% trans date_and_time=next_session_at|datetime(view.datetime_format) %}The next session in the schedule starts {{ date_and_time }}{% endtrans %}</p>
Expand Down
3 changes: 1 addition & 2 deletions funnel/templates/notifications/rsvp_yes_web.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% extends "notifications/layout_web.html.jinja2" %}
{%- from "macros.html.jinja2" import project_title %}
{% block content %}
<p>
{% trans project=project_title(view.rsvp.project), url=view.rsvp.project.url_for() -%}
{% trans project=view.rsvp.project.joined_title, url=view.rsvp.project.url_for() -%}
You registered for <a href="{{ url }}">{{ project }}</a>
{%- endtrans %}
</p>
Expand Down
3 changes: 1 addition & 2 deletions funnel/templates/notifications/update_new_email.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% extends "notifications/layout_email.html.jinja2" %}
{%- from "macros.html.jinja2" import project_title %}
{% block content %}

<p>{% trans actor=view.actor.pickername, project=project_title(view.update.project), project_url=view.update.project.url_for() %}{{ actor }} posted an update in <a href="{{ project_url }}">{{ project }}</a>:{% endtrans %}</p>
<p>{% trans actor=view.actor.pickername, project=view.update.project.joined_title, project_url=view.update.project.url_for() %}{{ actor }} posted an update in <a href="{{ project_url }}">{{ project }}</a>:{% endtrans %}</p>

<h1><a href="{{ view.update.url_for(_external=true, **view.tracking_tags()) }}">{{ view.update.title }}</a></h1>

Expand Down
3 changes: 1 addition & 2 deletions funnel/templates/notifications/update_new_web.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% extends "notifications/layout_web.html.jinja2" %}
{%- from "macros.html.jinja2" import project_title %}
{% block content %}
<p>
{%- trans actor=view.actor.pickername, project=project_title(view.update.project), project_url=view.update.project.url_for() -%}
{%- trans actor=view.actor.pickername, project=view.update.project.joined_title, project_url=view.update.project.url_for() -%}
{{ actor }} posted an update in <a href="{{ project_url }}">{{ project }}</a>:
{%- endtrans %}
</p>
Expand Down
8 changes: 4 additions & 4 deletions funnel/templates/search.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div class="user__box__header comment__header__details__user">
<h4 class="mui--text-bold zero-top-margin zero-bottom-margin"><a href="{{ item.url }}">{{ item.title_html }}</a></h4>
<h3 class="mui--text-body2 zero-top-margin zero-bottom-margin">
{%- if item.obj.speaker %}{{ item.obj.speaker }} <span class="mui--text-light">in</span>{% endif %} {{ item.obj.project.title }} <span class="mui--text-light">at</span> {{ item.obj.start_at_localized|time }}–{{ item.obj.end_at_localized|date }} <span class="mui--text-light">on</span> {{ item.obj.start_at_localized|date }}
{%- if item.obj.speaker %}{{ item.obj.speaker }} <span class="mui--text-light">{% trans %}in{% endtrans %}</span>{% endif %} {{ item.obj.project.title }} <span class="mui--text-light">at</span> {{ item.obj.start_at_localized|time }}–{{ item.obj.end_at_localized|date }} <span class="mui--text-light">{% trans %}on{% endtrans %}</span> {{ item.obj.start_at_localized|date }}
</h3>
</div>
</div>
Expand All @@ -36,9 +36,9 @@
<div class="user__box__header comment__header__details__user">
<h4 class="mui--text-bold zero-top-margin zero-bottom-margin"><a href="{{ item.url }}">{{ item.title_html }}</a></h4>
<h3 class="mui--text-body2 zero-top-margin zero-bottom-margin">
{%- if item.obj.first_user.fullname %}<span>{{ item.obj.first_user.fullname }}</span> <span class="mui--text-light">in</span>{% endif %} <span>{{ item.obj.project.full_title }} </span>
{%- if item.obj.first_user.fullname %}<span>{{ item.obj.first_user.fullname }}</span> <span class="mui--text-light">{% trans %}in{% endtrans %}</span>{% endif %} <span>{{ item.obj.project.joined_title }} </span>
{%- if item.obj.session and item.obj.session.start_at %}
<span><span class="mui--text-light">at</span> {{ item.obj.session.start_at_localized|time }}–{{ item.obj.session.end_at_localized|time }} <span class="mui--text-light">on</span> {{ item.obj.session.start_at_localized|date }}</span>
<span><span class="mui--text-light">at</span> {{ item.obj.session.start_at_localized|time }}–{{ item.obj.session.end_at_localized|time }} <span class="mui--text-light">{% trans %}on{% endtrans %}</span> {{ item.obj.session.start_at_localized|date }}</span>
{% endif %}
</h3>
</div>
Expand All @@ -50,7 +50,7 @@
<div class="user__box__header comment__header__details__user">
<h4 class="mui--text-bold zero-top-margin zero-bottom-margin"><a href="{{ item.url }}">{{ item.title_html }}</a></h4>
<h3 class="mui--text-body2 zero-top-margin zero-bottom-margin">
{%- if item.obj.user.fullname %}<span>{{ item.obj.user.fullname }}</span> <span class="mui--text-light">in</span>{% endif %} <span>{{ item.obj.project.full_title }} </span>
{%- if item.obj.user.fullname %}<span>{{ item.obj.user.fullname }}</span> <span class="mui--text-light">{% trans %}in{% endtrans %}</span>{% endif %} <span>{{ item.obj.project.joined_title }} </span>
</h3>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions funnel/views/notifications/project_starting_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def web(self):

def email_subject(self):
return self.emoji_prefix + _("{project} starts at {time}").format(
project=self.project.joined_title(),
project=self.project.joined_title,
time=time_filter(self.session.start_at_localized),
)

Expand All @@ -42,7 +42,7 @@ def email_content(self):
def sms(self) -> OneLineTemplate:
return OneLineTemplate(
text1=_("{project} starts at {time}.").format(
project=self.project.joined_title('>'),
project=self.project.joined_title,
time=time_filter(self.session.start_at_localized),
),
url=shortlink(
Expand Down
8 changes: 4 additions & 4 deletions funnel/views/notifications/proposal_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def web(self):

def email_subject(self):
return self.emoji_prefix + _("New submission in {project}: {proposal}").format(
proposal=self.proposal.title, project=self.project.joined_title()
proposal=self.proposal.title, project=self.project.joined_title
)

def email_content(self):
Expand All @@ -59,7 +59,7 @@ def email_content(self):
def sms(self) -> TwoLineTemplate:
return TwoLineTemplate(
text1=_("New submission in {project}:").format(
project=self.project.joined_title('>')
project=self.project.joined_title
),
text2=self.proposal.title,
url=shortlink(
Expand Down Expand Up @@ -88,7 +88,7 @@ def web(self):

def email_subject(self):
return self.emoji_prefix + _("Submission made to {project}: {proposal}").format(
project=self.proposal.project.joined_title(), proposal=self.proposal.title
project=self.proposal.project.joined_title, proposal=self.proposal.title
)

def email_content(self):
Expand All @@ -102,7 +102,7 @@ def email_content(self):
def sms(self) -> TwoLineTemplate:
return TwoLineTemplate(
text1=_("Your submission has been received in {project}:").format(
project=self.proposal.project.joined_title('>')
project=self.proposal.project.joined_title
),
text2=self.proposal.title,
url=shortlink(
Expand Down
12 changes: 6 additions & 6 deletions funnel/views/notifications/rsvp_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ def web(self):

def email_subject(self):
return self.emoji_prefix + _("Registration confirmation for {project}").format(
project=self.rsvp.project.joined_title()
project=self.rsvp.project.joined_title
)

def email_content(self):
return render_template(
'notifications/rsvp_yes_email.html.jinja2',
view=self,
jsonld=email.jsonld_view_action(
self.rsvp.project.joined_title(),
self.rsvp.project.joined_title,
self.rsvp.project.url_for(_external=True),
_("View project"),
),
Expand All @@ -93,7 +93,7 @@ def sms(self) -> OneLineTemplate:
template = _("You have registered for {project}")
return OneLineTemplate(
text1=template.format(
project=project.joined_title('>'),
project=project.joined_title,
datetime=datetime_filter(
next_at, self.datetime_format_sms, locale=get_locale()
),
Expand All @@ -118,15 +118,15 @@ def web(self):

def email_subject(self):
return self.emoji_prefix + _("Registration cancelled for {project}").format(
project=self.rsvp.project.joined_title()
project=self.rsvp.project.joined_title
)

def email_content(self):
return render_template(
'notifications/rsvp_no_email.html.jinja2',
view=self,
jsonld=email.jsonld_view_action(
self.rsvp.project.joined_title(),
self.rsvp.project.joined_title,
self.rsvp.project.url_for(_external=True),
_("View project"),
),
Expand All @@ -135,6 +135,6 @@ def email_content(self):
def sms(self) -> MessageTemplate:
return MessageTemplate(
message=_("You have cancelled your registration for {project}").format(
project=self.rsvp.project.joined_title('>'),
project=self.rsvp.project.joined_title,
),
)
4 changes: 2 additions & 2 deletions funnel/views/notifications/update_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def web(self):

def email_subject(self):
return self.emoji_prefix + _("{update} ({project})").format(
update=self.update.title, project=self.update.project.joined_title()
update=self.update.title, project=self.update.project.joined_title
)

def email_content(self):
Expand All @@ -46,7 +46,7 @@ def email_content(self):
def sms(self) -> TwoLineTemplate:
return TwoLineTemplate(
text1=_("Update in {project}:").format(
project=self.update.project.joined_title('>')
project=self.update.project.joined_title
),
text2=self.update.title,
url=shortlink(
Expand Down

0 comments on commit acfcbee

Please sign in to comment.