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

Misc adjustments #357

Merged
merged 7 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Profile(models.Model):

def get_location(self):
components = [self.city_town, self.state_province_region, self.country.name]
location = ', '.join(filter(None, components)) or 'None specified'
location = ', '.join(filter(None, components)) or None
return location

def __str__(self):
Expand Down
6 changes: 3 additions & 3 deletions communities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Community(models.Model):
contact_email = models.EmailField(max_length=254, null=True, blank=True)
image = models.ImageField(upload_to=community_img_path, blank=True, null=True)
support_document = models.FileField(upload_to=get_file_path, blank=True, null=True)
description = models.TextField(null=True, blank=True, validators=[MaxLengthValidator(200)])
description = models.TextField(null=True, validators=[MaxLengthValidator(200)])
city_town = models.CharField(max_length=80, blank=True, null=True)
state_province_region = models.CharField(verbose_name='state or province', max_length=100, blank=True, null=True)
country = CountryField(blank=True, null=True)
Expand All @@ -73,7 +73,7 @@ class Community(models.Model):

source_of_boundary = models.CharField(max_length=400, blank=True, null=True)
name_of_boundary = models.CharField(max_length=200, blank=True, null=True)
boundary = models.ForeignKey(Boundary, on_delete=models.CASCADE, null=True)
boundary = models.ForeignKey(Boundary, on_delete=models.CASCADE, blank=True, null=True)
share_boundary_publicly = models.BooleanField(default=True)

show_sp_connection = models.BooleanField(default=True)
Expand All @@ -85,7 +85,7 @@ class Community(models.Model):

def get_location(self):
components = [self.city_town, self.state_province_region, self.country.name]
location = ', '.join(filter(None, components)) or 'None specified'
location = ', '.join(filter(None, components)) or None
return location

def get_member_count(self):
Expand Down
4 changes: 2 additions & 2 deletions institutions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Institution(models.Model):
contact_email = models.EmailField(max_length=254, null=True, blank=True)
image = models.ImageField(upload_to=institution_img_path, blank=True, null=True)
support_document = models.FileField(upload_to=get_file_path, blank=True, null=True)
description = models.TextField(null=True, blank=True, validators=[MaxLengthValidator(200)])
description = models.TextField(null=True, validators=[MaxLengthValidator(200)])
ror_id = models.CharField(max_length=80, blank=True, null=True)
city_town = models.CharField(max_length=80, blank=True, null=True)
state_province_region = models.CharField(verbose_name='state or province', max_length=100, blank=True, null=True)
Expand All @@ -54,7 +54,7 @@ class Institution(models.Model):

def get_location(self):
components = [self.city_town, self.state_province_region, self.country]
location = ', '.join(filter(None, components)) or 'None specified'
location = ', '.join(filter(None, components)) or None
return location

def get_member_count(self):
Expand Down
18 changes: 7 additions & 11 deletions localcontexts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
from django.contrib.admin.models import LogEntry
from django.urls import path
from django.utils.translation import gettext as _
from django.utils.html import format_html, format_html_join
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.http import urlsafe_base64_encode
from django.utils.encoding import force_bytes

from django.apps import apps
from django.template.response import TemplateResponse
Expand All @@ -23,11 +21,10 @@
from django.contrib.auth.models import Group, User
from django.db import models
from django.shortcuts import redirect, render
from rest_framework_api_key.models import AbstractAPIKey

from accounts.models import Profile, UserAffiliation, SignUpInvitation, Subscription
from django_apscheduler.models import DjangoJob, DjangoJobExecution
from rest_framework_api_key.admin import APIKey, APIKeyModelAdmin
from rest_framework_api_key.admin import APIKeyModelAdmin
from api.models import AccountAPIKey
from django.contrib.auth.admin import UserAdmin, GroupAdmin
from django.contrib.auth.models import Group, User
Expand Down Expand Up @@ -1593,11 +1590,6 @@ class LabelTranslationVersionAdmin(admin.ModelAdmin):
)


class ProjectStatusAdmin(admin.ModelAdmin):
list_display = ('project', 'community', 'seen', 'status')
search_fields = ('project__title', 'community__community_name')


class NoticeDownloadTrackerAdmin(admin.ModelAdmin):
list_display = (
'user', 'institution', 'researcher', 'collections_care_notices',
Expand All @@ -1618,7 +1610,6 @@ class NoticeTranslationAdmin(admin.ModelAdmin):
list_display = ('notice', 'notice_type', 'language')


admin_site.register(ProjectStatus, ProjectStatusAdmin)
admin_site.register(Notice, NoticeAdmin)
admin_site.register(LabelVersion, LabelVersionAdmin)
admin_site.register(LabelTranslationVersion, LabelTranslationVersionAdmin)
Expand Down Expand Up @@ -1707,6 +1698,10 @@ class ProjectArchivedAdmin(admin.ModelAdmin):
class ProjectNoteAdmin(admin.ModelAdmin):
list_display = ('project', 'community')

class ProjectStatusAdmin(admin.ModelAdmin):
list_display = ('project', 'community', 'seen', 'status')
search_fields = ('project__title', 'community__community_name')


admin_site.register(Project, ProjectAdmin)
admin_site.register(ProjectContributors, ProjectContributorsAdmin)
Expand All @@ -1715,6 +1710,7 @@ class ProjectNoteAdmin(admin.ModelAdmin):
admin_site.register(ProjectActivity, ProjectActivityAdmin)
admin_site.register(ProjectArchived, ProjectArchivedAdmin)
admin_site.register(ProjectNote, ProjectNoteAdmin)
admin_site.register(ProjectStatus, ProjectStatusAdmin)


# RESEARCHERS ADMIN
Expand Down
2 changes: 1 addition & 1 deletion projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Project(models.Model):

source_of_boundary = models.CharField(max_length=400, blank=True, null=True)
name_of_boundary = models.CharField(max_length=200, blank=True, null=True)
boundary = models.ForeignKey(Boundary, on_delete=models.CASCADE, null=True)
boundary = models.ForeignKey(Boundary, on_delete=models.CASCADE, blank=True, null=True)

def has_labels(self):
if self.bc_labels.exists() or self.tk_labels.exists():
Expand Down
10 changes: 6 additions & 4 deletions templates/account_settings_pages/_update-account.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

<!-- Description -->
<div class="w-100 mb-8">
{{ update_form.description.label }} <br>
{{ update_form.description.label }}<span class="orange-text required-label" title="">*</span><br>
{{ update_form.description }}
{% if update_form.description.errors %}
<div class="msg-red w-80"><small>{{ update_form.description.errors.as_text }}</small></div>
Expand Down Expand Up @@ -119,9 +119,11 @@
<!-- Website -->
<div class="mb-8">
{{ update_form.website.label }}
<div class="tooltip"><strong>i</strong>
<span class="tooltiptext">A link to your platform's website</span>
</div>
{% if service_provider %}
<div class="tooltip"><strong>i</strong>
<span class="tooltiptext">A link to your platform's website</span>
</div>
{% endif %}
<br>
{{ update_form.website }}
{% if update_form.website.errors %}
Expand Down
6 changes: 2 additions & 4 deletions templates/accounts/member-invitations.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
</div>

<div>
<p class="dashcard-subheader">Institution | Members: {% if invite.institution.get_member_count < 10 %}0{{ invite.institution.get_member_count }}{% else %}{{ invite.institution.get_member_count }}{% endif %} |
Location: {{ invite.institution.get_location }}
<p class="dashcard-subheader">Institution | Members: {% if invite.institution.get_member_count < 10 %}0{{ invite.institution.get_member_count }}{% else %}{{ invite.institution.get_member_count }}{% endif %} {% with invite.institution.get_location as location %}{% if location %} | Location: {{ location }}{% endif %}{% endwith %}
</p>
</div>

Expand Down Expand Up @@ -107,8 +106,7 @@
</div>

<div>
<p class="dashcard-subheader">Community | Members: {% if invite.community.get_member_count < 10 %}0{{ invite.community.get_member_count }}{% else %}{{ invite.community.get_member_count }}{% endif %} |
Location: {{ invite.community.get_location }}
<p class="dashcard-subheader">Community | Members: {% if invite.community.get_member_count < 10 %}0{{ invite.community.get_member_count }}{% else %}{{ invite.community.get_member_count }}{% endif %}{% with invite.community.get_location as location %}{% if location %} | {{ location }}{% endif %}{% endwith %}
</p>
</div>

Expand Down
4 changes: 2 additions & 2 deletions templates/institutions/create-custom-institution.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
</div>
<div class="w-100">
<div class="pad-top-1-5 radio-group mb-1p">
<label for="inquiry_type" class="inquiry-label">Inquiry Type<span class="orange-text required-label" title="">*</span></label>
<label for="inquiry_type" class="inquiry-label">Subscription Type<span class="orange-text required-label" title="">*</span></label>
<div class="tooltip"><strong>i</strong>
<span class="tooltiptext">An institution inquiry type allows you to select the desired role for the subscription process.</span>
<span class="tooltiptext">An institution subscription type allows you to select the desired role for the subscription process.</span>
</div>
<br>
<div class="flex-this row ">
Expand Down
8 changes: 4 additions & 4 deletions templates/institutions/create-institution.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</div>

<div class="mt-8 w-100 flex-this">
<div class="w-50 mr-1p">
<div class="w-100 mr-1p">
<label class="pad-top-1-5" for="country">Country</label><br>
{{ form.country }}
</div>
Expand All @@ -79,12 +79,12 @@
</div>
<div class="w-100">
<div class="pad-top-1-5 radio-group mb-1p">
<label for="inquiry_type" class="inquiry-label">Inquiry Type<span class="orange-text required-label" title="">*</span></label>
<label for="inquiry_type" class="inquiry-label">Subscription Type<span class="orange-text required-label" title="">*</span></label>
<div class="tooltip"><strong>i</strong>
<span class="tooltiptext">An institution inquiry type allows you to select the desired role for the subscription process.</span>
<span class="tooltiptext">An institution subscription type allows you to select the desired role for the subscription process.</span>
</div>
<br>
<div class="flex-this row ">
<div class="flex-this row">
<label class="radio-container w-50 mt-2p">
<input class="pointer" type="radio" name="inquiry_type" value="Subscription">
<span class="ml-5">Subscription</span>
Expand Down
10 changes: 5 additions & 5 deletions templates/partials/infocards/_account-dashcard.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ <h3 class="dashcard-h3 darkteal-text">
<div class="mb-8">
<p class="dashcard-subheader m-0">
{% if researcher %}
Researcher | Location: {{ researcher.user.user_profile.get_location }}
Researcher {% with researcher.user.user_profile.get_location as location %}{% if location %} | Location: {{ location }}{% endif %}{% endwith %}
{% elif community %}
Community |
{% if member_role == 'admin' %}Administrator
{% elif member_role == 'editor' %}Editor
{% elif member_role == 'viewer' %}Viewer
{% endif %} |
Location: {{ community.get_location }}
{% endif %}
{% with community.get_location as location %}{% if location %} | Location: {{ location }}{% endif %}{% endwith %}
{% elif institution %}
Institution |
{% if member_role == 'admin' %}Administrator
{% elif member_role == 'editor' %}Editor
{% elif member_role == 'viewer' %}Viewer
{% endif %} |
Location: {{ institution.get_location }}
{% endif %}
{% with institution.get_location as location %}{% if location %} | Location: {{ location }}{% endif %}{% endwith %}
{% elif service_provider %}
Service Provider
{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion templates/partials/infocards/_community-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ <h3 class="dashcard-h3 darkteal-text">{{ community.community_name }}</h3>
</div>
<div>
<p class="dashcard-subheader">
Community | Members: {% if community.get_member_count < 10 %}0{{ community.get_member_count }}{% else %}{{ community.get_member_count }}{% endif %} | Location: {{ community.get_location }}
Community | Members: {% if community.get_member_count < 10 %}0{{ community.get_member_count }}{% else %}{{ community.get_member_count }}{% endif %}
{% with community.get_location as location %}{% if location %} | Location: {{ location }}{% endif %}{% endwith %}
</p>
</div>
<div>
Expand Down
3 changes: 2 additions & 1 deletion templates/partials/infocards/_institution-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ <h3 class="dashcard-h3 darkteal-text">{{ institution.institution_name }}</h3>
</div>
<div>
<p class="dashcard-subheader">
Institution | Members: {% if institution.get_member_count < 10 %}0{{ institution.get_member_count }}{% else %}{{ institution.get_member_count }}{% endif %} | Location: {{ institution.get_location }}
Institution | Members: {% if institution.get_member_count < 10 %}0{{ institution.get_member_count }}{% else %}{{ institution.get_member_count }}{% endif %}
{% with institution.get_location as location %}{% if location %} | Location: {{ location }}{% endif %}{% endwith %}
</p>
</div>
<div>
Expand Down
3 changes: 2 additions & 1 deletion templates/partials/infocards/_researcher-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ <h3 class="dashcard-h3 darkteal-text">
</div>
<div>
<p class="dashcard-subheader">
Researcher | Location: {{ researcher.user.user_profile.get_location }}
Researcher
{% with researcher.user.user_profile.get_location as location %}{% if location %} | Location: {{ location }}{% endif %}{% endwith %}
</p>
</div>
<div>
Expand Down
2 changes: 1 addition & 1 deletion templates/partials/infocards/_user-dashcard.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h2 class="mt-0 mb-0">{% display_name request.user %} </h2>
<h3 class="mt-0">{{ profile.affiliation }}</h3>
{% endif %}

<h4 class="mt-0">{{ profile.get_location }}</h4>
{% with profile.get_location as location %}{% if location %} <h4 class="mt-0">{{ location }}</h4> {% endif %}{% endwith %}

{% if profile.languages_spoken %}
<div class="flex-this">
Expand Down
6 changes: 3 additions & 3 deletions templates/public.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ <h3 class="dashcard-h3">{{ community }}</h3>
{% endif %}
</div>
<div>
<p class="dashcard-subheader">Community | {{ community.get_location }} </p>
<p class="dashcard-subheader">Community {% with community.get_location as location %}{% if location %} | Location: {{ location }}{% endif %}{% endwith %}</p>
</div>
<div><p class="dashcard-description description-sm">{% if community.description %}{{ community.description }}{% else %} No description provided. {% endif %}</p></div>

Expand Down Expand Up @@ -238,7 +238,7 @@ <h3 class="dashcard-h3">{{ institution }}</h3>
{% endif %}
</div>
<div>
<p class="dashcard-subheader">Institution | {{ institution.get_location }} </p>
<p class="dashcard-subheader">Institution {% with institution.get_location as location %}{% if location %} | Location: {{ location }}{% endif %}{% endwith %}</p>
</div>
<div><p class="dashcard-description description-sm">{% if institution.description %}{{ institution.description }}{% else %} No description provided. {% endif %}</p></div>

Expand Down Expand Up @@ -470,7 +470,7 @@ <h3 class="dashcard-h3">{% firstof researcher.user.get_full_name researcher.user
{% endif %}
</div>
<div>
<p class="dashcard-subheader">Researcher | {{ researcher.user.user_profile.get_location }} </p>
<p class="dashcard-subheader">Researcher {% with researcher.user.user_profile.get_location as location %}{% if location %} | Location: {{ location }}{% endif %}{% endwith %} </p>
</div>
<div><p class="dashcard-description description-sm">{% if researcher.description %}{{ researcher.description }}{% else %} No description provided. {% endif %}</p></div>
{% include 'partials/_alerts.html' %}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_accounts_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_str_method(self, new_user):
def test_get_location():
user = Profile.objects.create(
city_town=None, state_province_region=None, country=None)
assert user.get_location() == 'None specified'
assert user.get_location() == None

class TestSignUpInvitation(TestCase):
@pytest.mark.django_db
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_communities_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_get_location(self):
community.state_province_region = None
community.country = None
community.save()
expected_result = "None specified"
expected_result = None
result = community.get_location()
assert result == expected_result

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_institutions_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_get_location_none_specified(self):
new_institution.country = None
new_institution.save()

assert new_institution.get_location() == "None specified"
assert new_institution.get_location() == None

def test_get_member_count(self):
new_institution = self.institution
Expand Down
Loading