Skip to content

Commit

Permalink
Merge pull request #440 from CTPUG/customize-profile
Browse files Browse the repository at this point in the history
Hooks for customizing profile pages + styling improvements
  • Loading branch information
drnlm authored Oct 13, 2023
2 parents 0dbe10b + 960eeaa commit 241667c
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 190 deletions.
197 changes: 7 additions & 190 deletions wafer/users/templates/wafer.users/profile.html
Original file line number Diff line number Diff line change
@@ -1,197 +1,14 @@
{% extends "wafer/base.html" %}
{% load i18n %}
{% block title %}{{ object.userprofile.display_name }} - {{ WAFER_CONFERENCE_NAME }}{% endblock %}
{% block container_class %}userprofile{% endblock %}
{% block content %}
<section class="wafer wafer-profile">
{% with profile=object.userprofile %}
{% block preamble %}
{% endblock preamble %}
<div class="row">
<div class="col-md-2" id="profile-avatar">
{% block mugshot %}
{% with profile.avatar_url as avatar_url %}
{% if avatar_url != None %}
<img src="{{ profile.avatar_url }}">
{% endif %}
{% endwith %}
{% if can_edit %}
<a class="btn btn-secondary btn-sm" href="#" rel="popover" data-bs-toggle="popover"
data-bs-title="{% trans 'Changing your mugshot' %}" data-bs-html="true"
data-bs-placement="bottom">{% trans 'Edit Mugshot' %}</a>
<div class="popover-contents">
{% blocktrans trimmed %}
Pictures provided by <a href="https://www.libravatar.org/">libravatar</a>
(which falls back to <a href="https://secure.gravatar.com/">Gravatar</a>).<br>
Change your picture there.
{% endblocktrans %}
</div>
{% endif %}
{% endblock mugshot %}
</div>
<div class="col-md-10">
{% block side_menu %}
{% if can_edit %}
<ul class="float-end btn-group btn-group-vertical profile-links">
<li><a href="{% url 'wafer_user_edit' object.username %}" class="btn btn-secondary">{% trans 'Edit Account' %}</a></li>
<li><a href="{% url 'wafer_user_edit_profile' object.username %}" class="btn btn-secondary">{% trans 'Edit Profile' %}</a></li>
{% if WAFER_REGISTRATION_OPEN %}
{% if WAFER_REGISTRATION_MODE == 'ticket' and not profile.is_registered %}
{% url 'wafer_ticket_claim' as register_url %}
{% endif %}
{% if WAFER_REGISTRATION_MODE == 'custom' %}
{% url 'register' as register_url %}
{% endif %}
{% if register_url %}
<li><a href="{{ register_url }}" class="btn btn-secondary">{% if profile.is_registered %}{% trans 'Update registration' context "conference" %}{% else %}{% trans 'Register' context "conference" %}{% endif %}</a></li>
{% endif %}
{% endif %}
{% if WAFER_TALKS_OPEN %}
<li><a href="{% url 'wafer_talk_submit' %}" class="btn btn-secondary">{% trans 'Submit Talk Proposal' %}</a></li>
{% endif %}
</ul>
{% endif %}
{% endblock side_menu %}
{% spaceless %}
{% block name %}
<h1>
{% if profile.homepage %}
<a href="{{ profile.homepage_url }}">
{% endif %}
{{ profile.display_name }}
{% if profile.homepage %}
</a>
{% endif %}
</h1>
{% endblock name %}
{% block social %}
{% if profile.twitter_handle %}
<p>
<a href="https://twitter.com/{{ profile.twitter_handle }}" class="twitter-follow-button" data-bs-show-count="false">
{% blocktrans with handle=profile.twitter_handle %}Follow @{{ handle }}{% endblocktrans %}
</a>
</p>
{% endif %}
{% if profile.github_username %}
<p>
<a href="https://github.com/{{ profile.github_username }}">
{% blocktrans with username=profile.github_username %}GitHub: {{ username }}{% endblocktrans %}
</a>
</p>
{% endif %}
{% endblock social %}
{% endspaceless %}
</div>
</div>
{% if profile.bio %}
<div class="bio">
{{ profile.bio|linebreaks }}
</div>
{% endif %}
{% if can_edit %}
{% if profile.pending_talks.exists or profile.accepted_talks.exists or profile.provisional_talks.exists%}
{% block speaker_registered %}
{% if profile.is_registered %}
<div class="alert alert-success">
{% blocktrans trimmed %}
Registered
{% endblocktrans %}
</div>
{% else %}
<div class="alert alert-danger">
{% blocktrans trimmed %}
<strong>WARNING:</strong>
Talk proposal submitted, but speaker hasn't registered to attend.
{% endblocktrans %}
{% if WAFER_REGISTRATION_OPEN %}
{% trans "Register now!" %}
{% endif %}
</div>
{% endif %}
{% if WAFER_REGISTRATION_MODE == 'ticket' and profile.is_registered %}
<p>Tickets:
{{ profile.ticket_types }}
</p>
{% endif %}
{% endblock speaker_registered %}
{% endif %}
{% endif %}
{# Accepted talks are globally visible #}
{% if profile.accepted_talks.exists %}
<h2>{% trans 'Accepted Talks:' %}</h2>
{% for talk in profile.accepted_talks %}
<div class="card">
<div class="card-body">
<h3 class="card-title">
<a href="{{ talk.get_absolute_url }}">
{{ talk.title }}
</a>
</h3>
<p>{{ talk.abstract }}</p>
</div>
</div>
{% endfor %}
{% endif %}
{% if profile.cancelled_talks.exists %}
<h2>{% trans 'Cancelled Talks:' %}</h2>
{% for talk in profile.cancelled_talks %}
<div class="card">
<div class="card-body">
<h3 class="card-title">
<a href="{{ talk.get_absolute_url }}">
{{ talk.title }}
</a>
</h3>
<p>{{ talk.abstract }}</p>
</div>
</div>
{% endfor %}
{% endif %}
{# Submitted talk proposals are only visible to the owner #}
{% if can_edit %}
{% if profile.provisional_talks.exists %}
<h2>{% trans 'Provisionally Accepted Talks:' %}</h2>
{% for talk in profile.provisional_talks %}
<div class="card">
<div class="card-body">
<h3 class="card-title">
<a href="{{ talk.get_absolute_url }}">
{{ talk.title }}
</a>
</h3>
<p>{{ talk.abstract }}</p>
</div>
</div>
{% endfor %}
{% endif %}
{% if profile.pending_talks.exists %}
<h2>{% trans 'Submitted or Under Consideration Talks:' %}</h2>
{% for talk in profile.pending_talks %}
<div class="card">
<div class="card-body">
{% comment %}
Because this is one of the author's pending talks, we don't
need to check for edit permission's on the talk explictly.
This doesn't show the edit button for people with 'change-talk'
permissions, but we accept that tradeoff for simplicity here.
{% endcomment %}
<a href="{% url 'wafer_talk_edit' talk.pk %}"
class="float-end btn btn-secondary btn-lg">
{% trans 'Edit' %}
</a>
<h3 class="card-title">
<a href="{{ talk.get_absolute_url }}">
{{ talk.title }}
</a>
</h3>
<p>{{ talk.abstract }}</p>
</div>
</div>
{% endfor %}
{% endif %}
{% endif %}
{% endwith %}
</section>
<div class="wafer wafer-profile">
{% include "wafer.users/snippets/profile_10-preamble.html" %}
{% include "wafer.users/snippets/profile_20-bio.html" %}
{% include "wafer.users/snippets/profile_30-registered.html" %}
{% include "wafer.users/snippets/profile_40-talks.html" %}
{% include "wafer.users/snippets/profile_50-epilogue.html" %}
</div>
{% endblock content %}
{% block extra_foot %}
<script type="text/javascript">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{# Override this with anything you want to insert at the top of the page #}
65 changes: 65 additions & 0 deletions wafer/users/templates/wafer.users/snippets/profile_20-bio.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{% load i18n %}
{% with profile=object.userprofile %}
<section class="wafer-profile-bio">
<div class="row">
<div class="col-md-2" id="profile-avatar">
{% block mugshot %}
{% with profile.avatar_url as avatar_url %}
{% if avatar_url != None %}
<img src="{{ profile.avatar_url }}">
{% endif %}
{% endwith %}
{% if can_edit %}
<a class="btn btn-secondary btn-sm" href="#" rel="popover" data-bs-toggle="popover"
data-bs-title="{% trans 'Changing your mugshot' %}" data-bs-html="true"
data-bs-placement="bottom">{% trans 'Edit Mugshot' %}</a>
<div class="popover-contents">
{% blocktrans trimmed %}
Pictures provided by <a href="https://www.libravatar.org/">libravatar</a>
(which falls back to <a href="https://secure.gravatar.com/">Gravatar</a>).<br>
Change your picture there.
{% endblocktrans %}
</div>
{% endif %}
{% endblock mugshot %}
</div>
<div class="col-md-10">
{% include "wafer.users/snippets/profile_25-menu.html" %}
{% spaceless %}
{% block name %}
<h1>
{% if profile.homepage %}
<a href="{{ profile.homepage_url }}">
{% endif %}
{{ profile.display_name }}
{% if profile.homepage %}
</a>
{% endif %}
</h1>
{% endblock name %}
{% block social %}
{% if profile.twitter_handle %}
<p>
<a href="https://twitter.com/{{ profile.twitter_handle }}" class="twitter-follow-button" data-bs-show-count="false">
{% blocktrans with handle=profile.twitter_handle %}Follow @{{ handle }}{% endblocktrans %}
</a>
</p>
{% endif %}
{% if profile.github_username %}
<p>
<a href="https://github.com/{{ profile.github_username }}">
{% blocktrans with username=profile.github_username %}GitHub: {{ username }}{% endblocktrans %}
</a>
</p>
{% endif %}
{% endblock social %}
{% endspaceless %}
</div>
</div>
{% if profile.bio %}
<div class="bio">
{{ profile.bio|linebreaks }}
</div>
{% endif %}
</section>
{% endwith %}
25 changes: 25 additions & 0 deletions wafer/users/templates/wafer.users/snippets/profile_25-menu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% load i18n %}
{% with profile=object.userprofile %}
{% block side_menu %}
{% if can_edit %}
<ul class="float-end btn-group btn-group-vertical profile-links">
<li><a href="{% url 'wafer_user_edit' object.username %}" class="btn btn-secondary">{% trans 'Edit Account' %}</a></li>
<li><a href="{% url 'wafer_user_edit_profile' object.username %}" class="btn btn-secondary">{% trans 'Edit Profile' %}</a></li>
{% if WAFER_REGISTRATION_OPEN %}
{% if WAFER_REGISTRATION_MODE == 'ticket' and not profile.is_registered %}
{% url 'wafer_ticket_claim' as register_url %}
{% endif %}
{% if WAFER_REGISTRATION_MODE == 'custom' %}
{% url 'register' as register_url %}
{% endif %}
{% if register_url %}
<li><a href="{{ register_url }}" class="btn btn-secondary">{% if profile.is_registered %}{% trans 'Update registration' context "conference" %}{% else %}{% trans 'Register' context "conference" %}{% endif %}</a></li>
{% endif %}
{% endif %}
{% if WAFER_TALKS_OPEN %}
<li><a href="{% url 'wafer_talk_submit' %}" class="btn btn-secondary">{% trans 'Submit Talk Proposal' %}</a></li>
{% endif %}
</ul>
{% endif %}
{% endblock side_menu %}
{% endwith %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% load i18n %}
{% with profile=object.userprofile %}
{% if can_edit %}
{% if profile.pending_talks.exists or profile.accepted_talks.exists or profile.provisional_talks.exists%}
{% block speaker_registered %}
{% if profile.is_registered %}
<div class="alert alert-success">
{% blocktrans trimmed %}
Registered
{% endblocktrans %}
</div>
{% else %}
<div class="alert alert-danger">
{% blocktrans trimmed %}
<strong>WARNING:</strong>
Talk proposal submitted, but speaker hasn't registered to attend.
{% endblocktrans %}
{% if WAFER_REGISTRATION_OPEN %}
{% trans "Register now!" %}
{% endif %}
</div>
{% endif %}
{% if WAFER_REGISTRATION_MODE == 'ticket' and profile.is_registered %}
<p>Tickets:
{{ profile.ticket_types }}
</p>
{% endif %}
{% endblock speaker_registered %}
{% endif %}
{% endif %}
{% endwith %}
Loading

0 comments on commit 241667c

Please sign in to comment.