Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor core/home app views and serializers #663

Merged
merged 11 commits into from
Aug 18, 2023
2 changes: 1 addition & 1 deletion django/core/jinja2/account/login.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Use the social sign in buttons below to sign in to CoMSES with your <a href='htt
or <a href='https://orcid.org'>ORCID</a> account. If you don't have an existing CoMSES Net account this will create
a new account and prompt you for additional information. If you <em>do</em> have an existing CoMSES Net account and want
to link it with GitHub or ORCID, first sign in using your username / password below, then visit
<a href='{{url("home:account-profile")}}#local-signin'>your account profile page</a> to link your accounts.
<a href='{{url("core:account-profile")}}#local-signin'>your account profile page</a> to link your accounts.
</p>
{% include "includes/socialauth_login.jinja" %}
<hr>
Expand Down
15 changes: 11 additions & 4 deletions django/core/jinja2/base.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% set logout_url = url("account_logout") %}
{% set signup_url = url("account_signup") %}
{% set contact_url = slugurl('contact') %}
{% set profile_url = url('home:profile-detail', pk=user.pk) if user.is_authenticated else signup_url %}
{% set profile_url = url('core:profile-detail', pk=user.pk) if user.is_authenticated else signup_url %}

{% macro navbar() %}
<div class="fixed-top bg-light">
Expand Down Expand Up @@ -38,10 +38,10 @@
<a href='{{ slugurl("education") }}' class='nav-link'>Education</a>
</li>
<li class="nav-item">
<a href="{{ url('home:event-list') }}" class="nav-link">Events</a>
<a href="{{ url('core:event-list') }}" class="nav-link">Events</a>
</li>
<li class="nav-item">
<a href="{{ url('home:job-list') }}" class="nav-link">Jobs</a>
<a href="{{ url('core:job-list') }}" class="nav-link">Jobs</a>
</li>
<li class="nav-item">
<a href="/resources/" class="nav-link">Resources</a>
Expand Down Expand Up @@ -379,9 +379,16 @@
</div>
</section>
{% endblock introduction_section %}
<noscript>
<div class='alert alert-danger mt-3'>
<i class='fas fa-exclamation-triangle me-2'></i>
Javascript is disabled in your browser. Some of this site's functionality <b>will not work</b> or
be heavily degraded without it.
</div>
</noscript>
{% if not is_production() %}
<div class='alert alert-danger mt-3'>
<i class='fas fa-warning fa-2x'></i>
<i class='fas fa-flask me-2'></i>
You are currently accessing a <b>test version of the comses.net website</b>. Information that you
view or store here will <b>not be preserved</b> and may not be consistent.
</div>
Expand Down
10 changes: 5 additions & 5 deletions django/core/jinja2/common.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
{{ search_tag_href(tag, 'btn btn-tag btn-outline-secondary', category) }}
{% endmacro %}

{% macro institution_href(institution) %}
{% if institution %}
{%- if institution.url -%}
<a href='{{ institution.url }}' target='_blank'>{{ institution.name }}</a>
{% macro affiliation_href(affiliation) %}
{% if affiliation %}
{%- if affiliation.url -%}
<a href='{{ affiliation.url }}' target='_blank'>{{ affiliation.name }}</a>
{%- else -%}
{{ institution.name }}
{{ affiliation.name }}
{%- endif -%}
{% endif %}
{%- endmacro -%}
Expand Down
4 changes: 2 additions & 2 deletions django/core/jinja2/core/events/calendar.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
{% block content %}
{{ breadcrumb([{'text': 'Community Events' }]) }}
{{ subnav([
{'text': 'Calendar View', 'url': url('home:event-calendar'), 'active': True},
{'text': 'List View', 'url': url('home:event-list'), },
{'text': 'Calendar View', 'url': url('core:event-calendar'), 'active': True},
{'text': 'List View', 'url': url('core:event-list'), },
])
}}
<div class='my-3' id="event-calendar"></div>
Expand Down
12 changes: 6 additions & 6 deletions django/core/jinja2/core/events/list.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{% endif %}
<small class="text-muted text-end">Last updated {{ timesince(item.last_modified) }} ago</small>
<small>
Submitted by {{ member_profile_href(item.submitter) }}
Submitted by {{ member_profile_href(item.submitter.member_profile) }}
</small>
</div>
</div>
Expand Down Expand Up @@ -87,25 +87,25 @@

{% block introduction %}<h1>Community Events</h1>{% endblock %}

{% set pagination_block = paginator('home:event-list', __all__) %}
{% set pagination_block = paginator('core:event-list', __all__) %}

{% block top %}
{{ breadcrumb([{'text': 'Community Events' }]) }}
<div class="mb-4">
{{ subnav([
{'text': 'Calendar View', 'url': url('home:event-calendar')},
{'text': 'List View', 'url': url('home:event-list'), 'active': True},
{'text': 'Calendar View', 'url': url('core:event-calendar')},
{'text': 'List View', 'url': url('core:event-list'), 'active': True},
])}}
</div>
{% endblock %}

{% block search %}
{{ search_bar(url("home:event-list"), "Search Events") }}
{{ search_bar(url("core:event-list"), "Search Events") }}
{{ pagination_block }}
{% endblock %}

{% block content %}
{{ list_page(__all__, render_event, 'home:event-detail') }}
{{ list_page(__all__, render_event, 'core:event-detail') }}
{% if count > 10 %}
{{ pagination_block }}
{% endif %}
Expand Down
8 changes: 4 additions & 4 deletions django/core/jinja2/core/events/retrieve.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

{% block top %}
{{ breadcrumb([
{'text': 'Community Events', 'url': url('home:event-list')},
{'text': 'Community Events', 'url': url('core:event-list')},
{'text': title }
]) }}
{% endblock %}
Expand All @@ -38,7 +38,7 @@
<div class="card-body">
<div class='section'>
<b class="card-title">Submitter</b>
<p class="card-text">{{ member_profile_href(submitter) }}</p>
<p class="card-text">{{ member_profile_href(submitter.member_profile) }}</p>
<b class="card-title">Last updated</b>
<p class="card-text">{{ format_datetime_str(last_modified) }}</p>
<b class="card-title">When</b>
Expand Down Expand Up @@ -66,12 +66,12 @@
</div>
</div>
{% if has_change_perm %}
<a href="{{ url('home:event-edit', pk=id) }}">
<a href="{{ url('core:event-edit', pk=id) }}">
<div class="btn btn-primary my-1 w-100">Edit</div>
</a>
{% endif %}
{% if has_delete_perm %}
{{ delete_confirm_modal("Delete Event", title, url("home:event-delete", pk=id), csrf_input) }}
{{ delete_confirm_modal("Delete Event", title, url("core:event-delete", pk=id), csrf_input) }}
{% endif %}
{#{{ share_card(absolute_url) }}#}
{% endblock %}
Expand Down
8 changes: 4 additions & 4 deletions django/core/jinja2/core/jobs/list.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{% endif %}
<small class="text-muted text-end">Last updated {{ timesince(item.last_modified) }} ago</small>
<small>
Submitted by {{ member_profile_href(item.submitter) }}
Submitted by {{ member_profile_href(item.submitter.member_profile) }}
</small>
</div>
</div>
Expand All @@ -53,7 +53,7 @@

{% block introduction %}<h1>Jobs &amp; Appointments </h1>{% endblock %}

{% set pagination_block = paginator('home:job-list', __all__) %}
{% set pagination_block = paginator('core:job-list', __all__) %}

{% block top %}
{{ breadcrumb([
Expand All @@ -64,12 +64,12 @@
{% endblock %}

{% block search %}
{{ search_bar(url("home:job-list"), "Search Jobs") }}
{{ search_bar(url("core:job-list"), "Search Jobs") }}
{{ pagination_block }}
{% endblock %}

{% block content %}
{{ list_page(__all__, render_job, 'home:job-detail') }}
{{ list_page(__all__, render_job, 'core:job-detail') }}
{% if count == 0 %}
<div class='mt-3 alert alert-primary'>
<i class='fas fa-robot fa-2x'></i>
Expand Down
8 changes: 4 additions & 4 deletions django/core/jinja2/core/jobs/retrieve.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% endblock %}
{% block top %}
{{ breadcrumb([
{'url': url('home:job-list'), 'text': 'Jobs & Appointments' },
{'url': url('core:job-list'), 'text': 'Jobs & Appointments' },
{'text': title }
]) }}
{% endblock %}
Expand All @@ -38,7 +38,7 @@
<div class="card-body">
<div class='section'>
<b class="card-title">Submitter</b>
<p class='card-text'> {{ member_profile_href(submitter) }}</p>
<p class='card-text'> {{ member_profile_href(submitter.member_profile) }}</p>
{% if application_deadline %}
<b class="card-title">Application deadline</b>
<p class="card-text">{{ format_date_str(application_deadline) }}</p>
Expand All @@ -60,12 +60,12 @@
</div>
</div>
{% if has_change_perm %}
<a href="{{ url('home:job-edit', pk=id) }}">
<a href="{{ url('core:job-edit', pk=id) }}">
<div class="btn btn-primary my-1 w-100">Edit</div>
</a>
{% endif %}
{% if has_delete_perm %}
{{ delete_confirm_modal("Delete Job Posting", title, url("home:job-delete", pk=id), csrf_input) }}
{{ delete_confirm_modal("Delete Job Posting", title, url("core:job-delete", pk=id), csrf_input) }}
{% endif %}
{# {{ share_card(absolute_url) }} #}
{% endblock %}
Expand Down
6 changes: 3 additions & 3 deletions django/core/jinja2/core/member_profiles/list.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ search_tag_href, search_bar %}

{% block introduction %}<h1>Community</h1>{% endblock %}

{% set pagination_block = paginator("home:profile-list", paginator_data) %}
{% set pagination_block = paginator("core:profile-list", paginator_data) %}

{% block top %}
{{
breadcrumb([
{'url': '/community/', 'text': 'Community'},
{'url': url("home:profile-list"), 'text': 'Users'}
{'url': url("core:profile-list"), 'text': 'Users'}
])
}}
{% endblock %}

{% block search %}
{{ search_bar(url("home:profile-list"), "Search by name") }}
{{ search_bar(url("core:profile-list"), "Search by name") }}
{{ pagination_block }}
{% endblock %}

Expand Down
6 changes: 2 additions & 4 deletions django/core/jinja2/core/member_profiles/retrieve.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "sidebar_layout.jinja" %}
{% from "common.jinja" import breadcrumb, subnav, institution_href, search_tag_btn, render_social_profile_url %}
{% from "common.jinja" import breadcrumb, subnav, affiliation_href, search_tag_btn, render_social_profile_url %}
{% from "library/codebases/macros.jinja" import render_codebase_result, render_reviewer_feedback %}

{% block title %}User profile for {{ profile.name }}{% endblock %}
Expand Down Expand Up @@ -33,12 +33,11 @@
{% for degree in degrees %}
<p class='card-text'>{{ profile.degree }}</p>
{% endfor %}
{# consider marking primary institution #}
{% if profile.affiliations %}
<b class='card-title'>Affiliations</b>
<p class='card-text'>
{% for affiliation in profile.affiliations %}
{{ institution_href(affiliation) }}{{ ", " if not loop.last else "" }}
{{ affiliation_href(affiliation) }}{{ ", " if not loop.last else "" }}
{% endfor %}
</p>
{% endif %}
Expand Down Expand Up @@ -103,7 +102,6 @@
{% endif %}
</div>
<div class='tab-pane' id='code' role='tabpanel'>
{# FIXME: use codebase list component #}
{% for codebase in codebases %}
{{ render_codebase_result(codebase) }}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion django/core/management/commands/setup_frontend_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.conf import settings
from django.core.management.base import BaseCommand

from core.models import MemberProfile, User, Institution, ComsesGroups
from core.models import MemberProfile, User, ComsesGroups


class Command(BaseCommand):
Expand Down
21 changes: 21 additions & 0 deletions django/core/migrations/0019_cascade_delete_memberprofile_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.20 on 2023-08-17 16:56

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('core', '0018_remove_event_date_times'),
]

operations = [
migrations.AlterField(
model_name='memberprofile',
name='user',
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='member_profile', to=settings.AUTH_USER_MODEL),
),
]
Loading