Skip to content

Commit

Permalink
Replace profile_url with existing absolute_url
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Oct 25, 2023
1 parent 3cedd79 commit bac2704
Show file tree
Hide file tree
Showing 21 changed files with 64 additions and 85 deletions.
2 changes: 1 addition & 1 deletion funnel/assets/js/utils/ractive_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { USER_AVATAR_IMG_SIZE } from '../constants';
Ractive.DEBUG = false;

export const useravatar = Ractive.extend({
template: `{{#if user.profile_url && addprofilelink }}<a href="{{user.profile_url}}" class="nounderline">{{#if user.logo_url }}<img class="user__box__gravatar" src="{{ imgurl() }}" />{{else}}<div class="user__box__gravatar user__box__gravatar--initials" data-avatar-colour="{{ getAvatarColour(user.fullname) }}">{{ getInitials(user.fullname) }}</div>{{/if}}</a>{{else}}<span>{{#if user.logo_url }}<img class="user__box__gravatar" src="{{ imgurl() }}" />{{else}}<div class="user__box__gravatar user__box__gravatar--initials" data-avatar-colour="{{ getAvatarColour(user.fullname) }}">{{ getInitials(user.fullname) }}</div>{{/if}}</span>{{/if}}`,
template: `{{#if addprofilelink }}<a href="{{user.absolute_url}}" class="nounderline">{{#if user.logo_url }}<img class="user__box__gravatar" src="{{ imgurl() }}" />{{else}}<div class="user__box__gravatar user__box__gravatar--initials" data-avatar-colour="{{ getAvatarColour(user.fullname) }}">{{ getInitials(user.fullname) }}</div>{{/if}}</a>{{else}}<span>{{#if user.logo_url }}<img class="user__box__gravatar" src="{{ imgurl() }}" />{{else}}<div class="user__box__gravatar user__box__gravatar--initials" data-avatar-colour="{{ getAvatarColour(user.fullname) }}">{{ getInitials(user.fullname) }}</div>{{/if}}</span>{{/if}}`,
data: {
addprofilelink: true,
size: 'medium',
Expand Down
2 changes: 1 addition & 1 deletion funnel/assets/js/utils/vue_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { USER_AVATAR_IMG_SIZE } from '../constants';

export const userAvatarUI = Vue.component('useravatar', {
template:
'<a :href="user.profile_url" v-if="user.profile_url && addprofilelink" class="nounderline"><span class="user__box__wrapper" v-if="user.logo_url"><img class="user__box__gravatar" :src="imgurl"></span><div class="user__box__gravatar user__box__gravatar--initials" :data-avatar-colour="getAvatarColour(user.fullname)" v-else>{{ getInitials(user.fullname) }}</div></a v-if="user.profile_url && addprofilelink"></a><span v-else><img class="user__box__gravatar" :src="imgurl" v-if="user.logo_url"/><div class="user__box__gravatar user__box__gravatar--initials" :data-avatar-colour="getAvatarColour(user.fullname)" v-else>{{ getInitials(user.fullname) }}</span v-else>',
'<a :href="user.absolute_url" v-if="addprofilelink" class="nounderline"><span class="user__box__wrapper" v-if="user.logo_url"><img class="user__box__gravatar" :src="imgurl"></span><div class="user__box__gravatar user__box__gravatar--initials" :data-avatar-colour="getAvatarColour(user.fullname)" v-else>{{ getInitials(user.fullname) }}</div></a v-if="user.absolute_url && addprofilelink"></a><span v-else><img class="user__box__gravatar" :src="imgurl" v-if="user.logo_url"/><div class="user__box__gravatar user__box__gravatar--initials" :data-avatar-colour="getAvatarColour(user.fullname)" v-else>{{ getInitials(user.fullname) }}</span v-else>',
props: {
user: Object,
addprofilelink: {
Expand Down
19 changes: 6 additions & 13 deletions funnel/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class Account(UuidMixin, BaseMixin, Model):
'logo_url',
'banner_image_url',
'joined_at',
'profile_url',
'absolute_url',
'urls',
'is_user_profile',
'is_organization_profile',
Expand All @@ -362,7 +362,7 @@ class Account(UuidMixin, BaseMixin, Model):
'logo_url',
'website',
'joined_at',
'profile_url',
'absolute_url',
'is_verified',
},
'related': {
Expand All @@ -378,7 +378,7 @@ class Account(UuidMixin, BaseMixin, Model):
'description',
'logo_url',
'joined_at',
'profile_url',
'absolute_url',
'is_verified',
},
}
Expand Down Expand Up @@ -623,13 +623,6 @@ def has_public_profile(self) -> bool:

with_roles(has_public_profile, read={'all'}, write={'owner'})

@property
def profile_url(self) -> str | None:
"""Return optional URL to account profile page."""
return self.url_for(_external=True)

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

def is_profile_complete(self) -> bool:
"""Verify if profile is complete (fullname, username and contacts present)."""
return bool(self.title and self.name and self.has_verified_contact_info)
Expand Down Expand Up @@ -1297,7 +1290,7 @@ class DuckTypeAccount(RoleMixin):
uuid_b58: None = None
username: None = None
name: None = None
profile_url: None = None
absolute_url: None = None
email: None = None
phone: None = None

Expand All @@ -1318,7 +1311,7 @@ class DuckTypeAccount(RoleMixin):
'username',
'fullname',
'pickername',
'profile_url',
'absolute_url',
},
'call': {'views', 'forms', 'features', 'url_for'},
}
Expand All @@ -1329,7 +1322,7 @@ class DuckTypeAccount(RoleMixin):
'username',
'fullname',
'pickername',
'profile_url',
'absolute_url',
}
}

Expand Down
14 changes: 4 additions & 10 deletions funnel/models/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,16 @@ class Comment(UuidMixin, BaseMixin, Model):

__roles__ = {
'all': {
'read': {'created_at', 'urls', 'uuid_b58', 'has_replies'},
'read': {'created_at', 'urls', 'uuid_b58', 'has_replies', 'absolute_url'},
'call': {'state', 'commentset', 'view_for', 'url_for'},
},
'replied_to_commenter': {'granted_via': {'in_reply_to': '_posted_by'}},
}

__datasets__ = {
'primary': {'created_at', 'urls', 'uuid_b58'},
'related': {'created_at', 'urls', 'uuid_b58'},
'json': {'created_at', 'urls', 'uuid_b58'},
'primary': {'created_at', 'urls', 'uuid_b58', 'absolute_url'},
'related': {'created_at', 'urls', 'uuid_b58', 'absolute_url'},
'json': {'created_at', 'urls', 'uuid_b58', 'absolute_url'},
'minimal': {'created_at', 'uuid_b58'},
}

Expand Down Expand Up @@ -361,12 +361,6 @@ def _message_expression(cls):
message, read={'all'}, datasets={'primary', 'related', 'json', 'minimal'}
)

@property
def absolute_url(self) -> str:
return self.url_for()

with_roles(absolute_url, read={'all'}, datasets={'primary', 'related', 'json'})

@property
def title(self) -> str:
obj = self.commentset.parent
Expand Down
6 changes: 3 additions & 3 deletions funnel/models/sync_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ def has_public_profile(self) -> bool:
with_roles(has_public_profile, read={'all'})

@property
def profile_url(self) -> str | None:
return self.participant.profile_url if self.participant else None
def absolute_url(self) -> str | None:
return self.participant.absolute_url if self.participant else None

with_roles(profile_url, read={'all'})
with_roles(absolute_url, read={'all'})

@classmethod
def get(
Expand Down
2 changes: 1 addition & 1 deletion funnel/templates/account.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{{ faicon(icon='info-circle', icon_size='body2', baseline=true) }} <a href="{{ url_for('account_edit') }}" data-cy="add-username">{% trans %}Add username{% endtrans %} <span class="circle-icon">{{ faicon(icon='plus', icon_size='caption', baseline=false) }}</span></a>
</p>
{%- endif %}
<a href="{{ current_auth.user.profile_url }}"
<a href="{{ current_auth.user.absolute_url }}"
data-cy="my-profile"
class="nounderline">
{%- trans %}Go to account{% endtrans %}
Expand Down
26 changes: 9 additions & 17 deletions funnel/templates/account_menu.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,17 @@
<div class="user">
<div class="user__box">
{{ useravatar(current_auth.user, add_profile_link=true, size='big') }}
{% if current_auth.user.profile_url %}
<a href="{{ current_auth.user.profile_url }}"
class="user__box__header nounderline"
data-cy="profile">
{%- else %}
<div class="user__box__header">
<a href="{{ current_auth.user.absolute_url }}"
class="user__box__header nounderline"
data-cy="profile">
<div class="user__box__header__details">
<p class="mui--text-title text-bold mui--text-dark zero-bottom-margin">{{ current_auth.user.fullname }}</p>
{% if current_auth.user.username %}
<p class="mui--text-caption mui--text-light zero-bottom-margin">@{{ current_auth.user.username }}</p>
{% endif %}
<div class="user__box__header__details">
<p class="mui--text-title text-bold mui--text-dark zero-bottom-margin">{{ current_auth.user.fullname }}</p>
{% if current_auth.user.username %}
<p class="mui--text-caption mui--text-light zero-bottom-margin">@{{ current_auth.user.username }}</p>
{% endif %}
</div>
{% if current_auth.user.profile_url %}
{{ faicon(icon='chevron-right', icon_size='subhead', baseline=false, css_class="user__box__header__icon mui--text-dark") }}
</a>
{%- else %}
</div>
{% endif %}
{{ faicon(icon='chevron-right', icon_size='subhead', baseline=false, css_class="user__box__header__icon mui--text-dark") }}
</a>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions funnel/templates/account_organizations.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{% for orgmem in current_auth.user.views.organizations_as_admin() %}
<li class="flex-wrapper bottom-padding">
<div>
<a href="{{ orgmem.account.profile_url }}"
<a href="{{ orgmem.account.absolute_url }}"
class="nounderline">
<span class="profile-avatar profile-avatar--bigger margin-right">
{%- if orgmem.account.logo_url.url %}
Expand All @@ -44,7 +44,7 @@
</a>
</div>
<div>
<a href="{{ orgmem.account.profile_url }}"
<a href="{{ orgmem.account.absolute_url }}"
class="nounderline display-block margin-bottom">
<p class="profile-avatar-title mui--text-dark mui--text-subhead text-bold">
{{ orgmem.account.title }}
Expand Down
8 changes: 4 additions & 4 deletions funnel/templates/macros.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@
{%- else %}
{%- set imgsize = 48 %}
{% endif %}
{% if user.profile_url and add_profile_link %}<a href="{{ user.profile_url }}" class="nounderline">{% endif %}
{% if add_profile_link %}<a href="{{ user.absolute_url }}" class="nounderline">{% endif %}
{% if user.logo_url %}
<img class="user__box__gravatar {% if css_class %}{{ css_class }}{% endif %}" src="{{ user.logo_url.resize(imgsize) }}" alt="{{ user.title }}"/>
{%- elif user.title %}
<div class="user__box__gravatar user__box__gravatar--initials {% if css_class %}{{ css_class }}{% endif %}" role="img" aria-label="{{ user.title }}" data-avatar-colour="{{ user.views and user.views.avatar_color_code or '' }}">{{ user.title|initials }}</div>
{% endif %}
{% if user.profile_url and add_profile_link %}</a>{% endif %}
{% if add_profile_link %}</a>{% endif %}
{%- endmacro %}

{%- macro list_sponsors(sponsors) %}
Expand All @@ -300,7 +300,7 @@
<div class="flex-wrapper flex-wrapper--center">
<div class="user user--smaller">
<div class="user__box">
<a {% if sponsor_public %}href="{{ sponsorship.member.profile_url }}"{% endif %} class="nounderline">
<a {% if sponsor_public %}href="{{ sponsorship.member.absolute_url }}"{% endif %} class="nounderline">
{%- if sponsorship.member.logo_url.url %}
<img class="user__box__gravatar" src="{{ sponsorship.member.logo_url.resize(img_size.profile_logo_small) }}" alt="{{ sponsorship.member.title }}"/>
{%- else %}
Expand All @@ -309,7 +309,7 @@
</a>
</div>
</div>
<a {% if sponsor_public %}href="{{ sponsorship.member.profile_url }}"{% endif %} class="mui--text-dark mui--text-subhead text-bold nounderline" data-cy="profile-link">{{ sponsorship.member.title }}</a>
<a {% if sponsor_public %}href="{{ sponsorship.member.absolute_url }}"{% endif %} class="mui--text-dark mui--text-subhead text-bold nounderline" data-cy="profile-link">{{ sponsorship.member.title }}</a>
</div>
{%- endwith %}
{%- endfor %}
Expand Down
4 changes: 2 additions & 2 deletions funnel/templates/profile_layout.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@
<div class="grid__col-md-6 grid__col-lg-7 mui--text-left spotlight-container__details mui--hidden-xs mui--hidden-sm mui--hidden-md">
<div class="flex-wrapper flex-wrapper--center flex-wrapper--space-between margin-bottom">
<div class="flex-wrapper flex-wrapper--center">
<a href="{{ featured_project.account.profile_url }}" class="profile-avatar margin-right" data-ga="View account">
<a href="{{ featured_project.account.absolute_url }}" class="profile-avatar margin-right" data-ga="View account">
{%- if featured_project.account.logo_url.url %}
<img src="{{ featured_project.account.logo_url.resize(img_size.profile_logo_small) }}" alt="{{ featured_project.account.title }}"/>
{% else %}
<img src="{{ url_for('static', filename='img/default-profile-logo.png') }}" alt="{{ featured_project.account.title }}"/>
{% endif %}
</a>
<a href="{{ featured_project.account.profile_url }}" class="profile-avatar-title mui--text-subhead text-bold mui--text-dark nounderline" data-ga="View account">{{ featured_project.account.title }}</a>
<a href="{{ featured_project.account.absolute_url }}" class="profile-avatar-title mui--text-subhead text-bold mui--text-dark nounderline" data-ga="View account">{{ featured_project.account.title }}</a>
</a>
</div>
{%- if not current_auth.is_anonymous %}
Expand Down
2 changes: 1 addition & 1 deletion funnel/templates/project_comments.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
divElem: "#comments-wrapper",
commentTemplate: '#comment-template',
isuserloggedin: {% if current_auth.user -%}true{% else %}false{% endif %},
user: {% if current_auth.user -%}{{ { 'fullname': current_auth.user.fullname, 'avatar': current_auth.user.logo_url, 'profile_url': current_auth.user.profile_url }|tojson }}{% else %}{}{% endif %},
user: {% if current_auth.user -%}{{ { 'fullname': current_auth.user.fullname, 'avatar': current_auth.user.logo_url, 'absolute_url': current_auth.user.absolute_url }|tojson }}{% else %}{}{% endif %},
loginUrl: "{{ url_for('login') }}",
lastSeenUrl: {% if subscribed %}{{ last_seen_url|tojson }}{% else %}false{% endif %},
};
Expand Down
14 changes: 7 additions & 7 deletions funnel/templates/project_layout.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<div class="top-padding bottom-padding project-details__box__title">
<div class="project-banner__profile-details">
{%- if project.account.logo_url.url %}
<a href="{{ project.account.profile_url }}" class="project-banner__profile-details__logo-wrapper" data-ga="View account">
<a href="{{ project.account.absolute_url }}" class="project-banner__profile-details__logo-wrapper" data-ga="View account">
<img class="project-banner__profile-details__logo_wrapper__logo" src="{{ project.account.logo_url.resize(img_size.profile_logo_small) }}" alt="{{ project.account.title }}"/>
</a>
{% endif %}
Expand Down Expand Up @@ -323,7 +323,7 @@
<div class="flex-wrapper flex-wrapper--center">
<div class="user user--smaller">
<div class="user__box">
<a href="{{ project.account.profile_url }}" class="nounderline">
<a href="{{ project.account.absolute_url }}" class="nounderline">
{%- if project.account.logo_url.url %}
<img class="user__box__gravatar" src="{{ project.account.logo_url.resize(img_size.profile_logo_small) }}" alt="{{ project.account.title }}"/>
{%- else %}
Expand All @@ -332,10 +332,10 @@
</a>
</div>
</div>
<a href="{{ project.account.profile_url }}" class="mui--text-dark mui--text-subhead text-bold nounderline" data-cy="profile-link">{{ project.account.title }}</a>
<a href="{{ project.account.absolute_url }}" class="mui--text-dark mui--text-subhead text-bold nounderline" data-cy="profile-link">{{ project.account.title }}</a>
</div>
{% if project.account.description.html %}
<div class="mui--text-body2 mui--text-light margin-bottom">{{ project.account.description.html|preview(min=200, max=300) }} <a href="{{ project.account.profile_url }}" class="chip mui--text-body2 nounderline">{% trans %}more{% endtrans %}{{ faicon(icon='caret-right-solid', baseline=false, css_class="mui--align-middle") }}</a></div>
<div class="mui--text-body2 mui--text-light margin-bottom">{{ project.account.description.html|preview(min=200, max=300) }} <a href="{{ project.account.absolute_url }}" class="chip mui--text-body2 nounderline">{% trans %}more{% endtrans %}{{ faicon(icon='caret-right-solid', baseline=false, css_class="mui--align-middle") }}</a></div>
{% endif %}
</div>
</div>
Expand Down Expand Up @@ -363,7 +363,7 @@
<div class="flex-wrapper flex-wrapper--center">
<div class="user user--smaller">
<div class="user__box">
<a {% if sponsor_public %}href="{{ sponsorship.member.profile_url }}"{% endif %} class="nounderline">
<a {% if sponsor_public %}href="{{ sponsorship.member.absolute_url }}"{% endif %} class="nounderline">
{%- if sponsorship.member.logo_url.url %}
<img class="user__box__gravatar" src="{{ sponsorship.member.logo_url.resize(img_size.profile_logo_small) }}" alt="{{ sponsorship.member.title }}"/>
{%- else %}
Expand All @@ -372,14 +372,14 @@
</a>
</div>
</div>
<a {% if sponsor_public %}href="{{ sponsorship.member.profile_url }}"{% endif %} class="mui--text-dark mui--text-subhead text-bold nounderline" data-cy="profile-link">{{ sponsorship.member.title }}</a>
<a {% if sponsor_public %}href="{{ sponsorship.member.absolute_url }}"{% endif %} class="mui--text-dark mui--text-subhead text-bold nounderline" data-cy="profile-link">{{ sponsorship.member.title }}</a>
{% if current_auth.user and current_auth.user.is_site_editor %}
<a href="{{ sponsorship.url_for('edit') }}" rel="modal:open" aria-label="{% trans %}Edit sponsor{% endtrans %}" data-ga="Edit sponsor" data-cy="edit-sponsor" role="button" aria-haspopup="true">{{ faicon(icon='edit', baseline=false, css_class="mui--text-light mui--align-middle fa-icon--left-margin fa-icon--right-margin") }}</a>
<a href="{{ sponsorship.url_for('remove') }}" rel="modal:open" aria-label="{% trans %}Remove sponsor{% endtrans %}" data-ga="Remove sponsor" data-cy="remove-sponsor" role="button" aria-haspopup="true">{{ faicon(icon='trash-alt', baseline=false, css_class="mui--text-light mui--align-middle") }}</a>
{% endif %}
</div>
{% if sponsorship.member.description.html %}
<div class="mui--text-body2 mui--text-light margin-bottom">{{ sponsorship.member.description.html|preview(min=200, max=300) }} {% if sponsor_public %}<a href="{{ sponsorship.member.profile_url }}" class="chip mui--text-body2 nounderline">{% trans %}more{% endtrans %}{{ faicon(icon='caret-right-solid', baseline=false, css_class="mui--align-middle") }}</a>{% endif %}</div>
<div class="mui--text-body2 mui--text-light margin-bottom">{{ sponsorship.member.description.html|preview(min=200, max=300) }} {% if sponsor_public %}<a href="{{ sponsorship.member.absolute_url }}" class="chip mui--text-body2 nounderline">{% trans %}more{% endtrans %}{{ faicon(icon='caret-right-solid', baseline=false, css_class="mui--align-middle") }}</a>{% endif %}</div>
{% endif %}
{% if sponsorship.is_promoted %}
<div class="margin-bottom"><p class="mui--text-body2 text-bold mui--text-light zero-bottom-margin">{{ faicon(icon='angle-double-up', baseline=false, css_class="mui--text-light fa-icon--right-margin mui--align-middle") }}<span data-cy="promoted">{% trans %}Promoted{% endtrans %}</span></p></div>
Expand Down
Loading

0 comments on commit bac2704

Please sign in to comment.