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

Merge Staging into Production, 2023-06-16 edition #752

Merged
merged 126 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
97cf3ce
add debug toolbar config
lucasmarchd01 Jun 1, 2023
3063d78
notation detail page: add title attribute to all sources, displaying …
jacobdgm Jun 5, 2023
ab03073
feast detail page: improve formatting of Notes
jacobdgm Jun 5, 2023
b1078f1
feast detail page: hide lists of chants/sources when lists are empty
jacobdgm Jun 5, 2023
bd51c9a
Update README.md
jacobdgm Jun 5, 2023
eb3986d
Merge pull request #696 from jacobdgm/notation-siglum
jacobdgm Jun 6, 2023
3d2e15f
Merge pull request #697 from jacobdgm/feast-detail-formatting
jacobdgm Jun 6, 2023
e4c5acd
Update README.md
jacobdgm Jun 6, 2023
308e9c7
csv export: allow csv for unpublished source to be accessed while use…
jacobdgm Jun 6, 2023
bd25dc8
update genre and office dropdown menus
lucasmarchd01 Jun 6, 2023
275411d
csv export: update path to include .csv suffix, to match OldCantus
jacobdgm Jun 6, 2023
167a167
Update README.md
lucasmarchd01 Jun 6, 2023
f8d385c
Update README.md
lucasmarchd01 Jun 6, 2023
ed49910
Update README.md
jacobdgm Jun 6, 2023
2a23e1b
Update README.md
jacobdgm Jun 6, 2023
8ee3492
set up redirect to csv export view, so people can use the same path a…
jacobdgm Jun 6, 2023
b6e14c0
improve path to csv export API, to better function as a URI
jacobdgm Jun 6, 2023
2a51116
add custom model choice field for genre and office
lucasmarchd01 Jun 6, 2023
4ae3a94
Source Detail page: for CSV export, trigger download upon click
jacobdgm Jun 6, 2023
92d7d8b
Update README.md
jacobdgm Jun 6, 2023
471bfaa
Chant List page: prevent table from displaying when there are no results
jacobdgm Jun 6, 2023
2eaec8c
improve indentation in template
jacobdgm Jun 6, 2023
bf4a57f
update docstring
lucasmarchd01 Jun 6, 2023
e1a211d
add comments
lucasmarchd01 Jun 6, 2023
7e873c3
Merge pull request #702 from jacobdgm/csv-export
jacobdgm Jun 6, 2023
63ccd31
Merge pull request #704 from jacobdgm/smushed
jacobdgm Jun 6, 2023
62aa327
Merge pull request #703 from lucasmarchd01/issue-699
lucasmarchd01 Jun 6, 2023
e0949fb
article list page: add pagination links
jacobdgm Jun 6, 2023
b3102a8
article list: change pagination to 10-per-page rather than 100
jacobdgm Jun 6, 2023
4e457ac
Article List page: ensure article preview is displayed
jacobdgm Jun 6, 2023
be0f6cf
improve formatting of article list page
jacobdgm Jun 6, 2023
9945e13
set up redirect so /news/ redirects to article list page
jacobdgm Jun 6, 2023
6804e10
fix syllabize_melody() in cases where volpiano is an empty or nearly-…
jacobdgm Jun 6, 2023
59d0e9f
update tests to account for new CSV Export URL path
jacobdgm Jun 6, 2023
324ccec
tweak syllabize_melody to return an empty list where it had returned …
jacobdgm Jun 6, 2023
3cadb6d
Update README.md
jacobdgm Jun 7, 2023
4ee4859
Merge pull request #706 from jacobdgm/articles
jacobdgm Jun 7, 2023
70e4473
Merge pull request #708 from jacobdgm/volpiano-newline
jacobdgm Jun 7, 2023
108615d
Redirect /node/ urls to their corresponding detail page in NewCantus
Jun 8, 2023
256a343
set up email configuration
jacobdgm Jun 8, 2023
7a392cf
Update README.md
lucasmarchd01 Jun 8, 2023
c1d3923
add overflow div to chant detail page
lucasmarchd01 Jun 8, 2023
cc67d0a
chant div to class table-responsive
lucasmarchd01 Jun 8, 2023
a5ccacf
fix addendum field in chant edit
lucasmarchd01 Jun 8, 2023
b24990d
fix addendum field in chant create
lucasmarchd01 Jun 8, 2023
f7d1a33
formatting for narrow windows in chant detail
lucasmarchd01 Jun 8, 2023
2f539c4
tweak change password and login pages
jacobdgm Jun 8, 2023
4c90726
set up password reset pages
jacobdgm Jun 8, 2023
f8a2ad1
add comment to password_reset_complete_.html
jacobdgm Jun 8, 2023
a024b17
Login page: add link to reset password
jacobdgm Jun 8, 2023
164d74e
Password Reset page: tweak displayed message
jacobdgm Jun 8, 2023
131a884
move {% extends %} tags to top of files
jacobdgm Jun 8, 2023
c4bdcb4
Merge pull request #680 from lucasmarchd01/django-debug-toolbar-2
jacobdgm Jun 9, 2023
dfbd803
Merge pull request #720 from lucasmarchd01/issue-690
lucasmarchd01 Jun 9, 2023
ce4d1e9
Update documentation and wrote tests for /node/ redirect fix
Jun 9, 2023
9876189
Merge branch 'develop' into email
jacobdgm Jun 9, 2023
a3e9087
Set up redirects for /indexer/ urls
Jun 9, 2023
0d0aa00
rename password reset templates
jacobdgm Jun 9, 2023
082de58
rename password reset templates
jacobdgm Jun 9, 2023
d625571
make sure urls.py is set up correctly for resetting passwords via email
jacobdgm Jun 9, 2023
669bd67
set unusable password for dummy users
lucasmarchd01 Jun 12, 2023
bcb96ad
Refactor comments
lucasmarchd01 Jun 12, 2023
7de9aab
Merge pull request #726 from lucasmarchd01/issue-713
jacobdgm Jun 12, 2023
af56d71
Display "No chants found" message on chant list
lucasmarchd01 Jun 12, 2023
bbc3c4c
Merge pull request #729 from lucasmarchd01/issue-718
jacobdgm Jun 12, 2023
b6d9ea9
Hide table if no sources found from search
lucasmarchd01 Jun 12, 2023
89f4877
Hide table if no sequences found in search
lucasmarchd01 Jun 12, 2023
93f0ab4
Merge pull request #731 from lucasmarchd01/issue-730
jacobdgm Jun 12, 2023
31f1484
urls.py: 'update success_url's of several password reset views
jacobdgm Jun 12, 2023
6f73c33
improve indentation in reset_password_confirm.html
jacobdgm Jun 12, 2023
010635b
provenance detail: ensure unpublished sources aren't displayed
jacobdgm Jun 12, 2023
f91a51f
century detail: add title attribute to each source in list of sources
jacobdgm Jun 12, 2023
33c076a
add tests to ensure unpublished sources not displayed on provenance d…
jacobdgm Jun 12, 2023
546ac98
Merge pull request #733 from jacobdgm/provenance-unpublished
jacobdgm Jun 12, 2023
6a60764
Improve code readability and documentation
Jun 13, 2023
0ed205a
Merge pull request #721 from jacobdgm/email
jacobdgm Jun 13, 2023
f84e5a3
Update test to use correct Faker method
Jun 13, 2023
8e1a564
Hide Full text & volpiano editor and proofreading links
lucasmarchd01 Jun 13, 2023
1f3d62b
Change table formatting and hide certain links
lucasmarchd01 Jun 13, 2023
d9c9cb0
Merge pull request #739 from lucasmarchd01/issue-735-2
jacobdgm Jun 14, 2023
b85c000
Make final changes to /node/ url redirect method
Jun 14, 2023
ee90cee
all_all_users.py: give newly created users a random password
jacobdgm Jun 14, 2023
3a9fdb8
add_all_users.py: ensure newly-created users' full_name is set
jacobdgm Jun 14, 2023
71a40a6
add a type annotation
jacobdgm Jun 14, 2023
3b8a0b0
Merge pull request #716 from DDMAL/node-url-redirect
PythonSemicolon Jun 14, 2023
19ab001
Merge branch 'develop' of github.com:DDMAL/CantusDB into indexer-redi…
Jun 14, 2023
d5e2572
Incorporate changes after /nonde/ redirect merge
Jun 14, 2023
c1a526a
Merge pull request #742 from jacobdgm/sync-users-random-pass
jacobdgm Jun 14, 2023
3a4517f
Fix typo and refactor User call
Jun 14, 2023
390f868
Merge pull request #725 from DDMAL/indexer-redirect
jacobdgm Jun 14, 2023
8190bce
update tests for user app
jacobdgm Jun 14, 2023
3c08005
update formatting to conform to black
jacobdgm Jun 14, 2023
80ecef9
Merge pull request #744 from DDMAL/develop
lucasmarchd01 Jun 14, 2023
1aaca1e
Merge pull request #743 from jacobdgm/user-tests
jacobdgm Jun 14, 2023
3e3efab
ensure Admin Navigation section in footer is only shown to contributo…
jacobdgm Jun 15, 2023
528214c
split login and logout into separate words when used as verbs
jacobdgm Jun 16, 2023
466abb2
Merge pull request #749 from jacobdgm/admin-footer
jacobdgm Jun 16, 2023
4a67d01
Merge pull request #750 from DDMAL/develop
jacobdgm Jun 16, 2023
a1e0ab2
Change black formatting
lucasmarchd01 Jun 16, 2023
5a5013f
Update field descriptions for source model
lucasmarchd01 Jun 16, 2023
ef8857d
Add sources created by user card and helper tag
lucasmarchd01 Jun 16, 2023
2feab3e
default.html: request user permissions to view source add option
lucasmarchd01 Jun 16, 2023
bd079fd
Merge branch 'develop' into source-sidebar
lucasmarchd01 Jun 16, 2023
0d74b72
add else statement
lucasmarchd01 Jun 16, 2023
9823f72
Merge branch 'source-sidebar' of https://github.com/lucasmarchd01/Can…
lucasmarchd01 Jun 16, 2023
4f9be8d
change if/else logic
lucasmarchd01 Jun 16, 2023
7b56279
change page2 to page
lucasmarchd01 Jun 16, 2023
6de8692
Merge pull request #753 from lucasmarchd01/source-sidebar
jacobdgm Jun 19, 2023
27177fa
Display correct 404 page for /node/ and /indexer/ redirects
Jun 19, 2023
742a843
Merge pull request #756 from DDMAL/redirect-404
jacobdgm Jun 19, 2023
59348ae
default.html: hide edit chants link from mysources
lucasmarchd01 Jun 19, 2023
3687d56
provenance detail page: fix bug in template causing unpublished sourc…
jacobdgm Jun 19, 2023
fc88cf8
reformat files to conform to Black
jacobdgm Jun 19, 2023
eabfb26
edit-chants: load page when no chants exist in source
lucasmarchd01 Jun 19, 2023
e9842f9
update test views
lucasmarchd01 Jun 19, 2023
b422866
Merge pull request #760 from jacobdgm/provenance-bug
jacobdgm Jun 19, 2023
b354bc8
reorder if/else in get_context_data
lucasmarchd01 Jun 19, 2023
42298a5
add try/except block for folio index ValueError
lucasmarchd01 Jun 19, 2023
980f803
change comment on chant-edit for source with no chant
lucasmarchd01 Jun 19, 2023
ceafeed
remove if statement
lucasmarchd01 Jun 19, 2023
74b461b
change if statement logic clarity
lucasmarchd01 Jun 19, 2023
5ac110f
source-list: add responsive table
lucasmarchd01 Jun 19, 2023
222d85a
Merge pull request #759 from lucasmarchd01/issue-758
lucasmarchd01 Jun 20, 2023
95c542d
Merge pull request #763 from lucasmarchd01/issue-711
jacobdgm Jun 20, 2023
b31fc67
Merge pull request #766 from lucasmarchd01/issue-765
jacobdgm Jun 20, 2023
d1aa9c9
Merge pull request #767 from DDMAL/develop
lucasmarchd01 Jun 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,29 @@ Discrepancies between text stored in the CantusDB database and the manuscript te

### Differences in functionality/behavior:
#### Visible to All Users (Logged-In and Anonymous)
- General:
- The formatting/style of the entire site is slightly different.
- In some places, links (to Genre, Office, Feast detail pages, etc.) have been added where there were no links in OldCantus.
- In some places, title attributes have been added, especially where abbreviations are displayed (visible on mouse-over).
- Certain pages have an upward-pointing arrow at the bottom that brings the user back to the top of the page. We don't currently plan to implement this.
- If you click on the items in the header on OldCantus, it usually links you to one of the pages within the dropdown. On NewCantus, you need to open the dropdown and click on an item before you go to any of the pages. We have no plans to implement this on NewCantus, as OldCantus's system is hard to use on mobile devices (for a sad chuckle, check out https://cantus.uwaterloo.ca/about, which you get when you click/tap on "About")
- Homepage:
- When logged out, OldCantus displays a sidebar displaying recently posted articles. NewCantus displays this sidebar, but only displays the articles' titles, rather than the full content of the article (Currently, we don't plan to display the full content of news articles here)
- Article List page:
- Images from within the news stories are not displayed on the Article List page, whereas they are in OldCantus. (Currently, we don't plan to display images on this page)
- Articles were manually copied from OldCantus to New, and when I initially did this, I preserved the date but not the time. It's fine that most of the timestamps say "00:00".
- Source List:
- NewCantus is paginating the sources list page to display 100 sources per page. This is not implemented in OldCantus and is an intentional chant
- Chant Search:
- New Cantus will do a full text search by keyword by default whereas OldCantus will display options to do either a full text search or a Cantus Index search (if the user clicks on the main Chant Search menu option)
- Provenance detail page - on OldCantus, the Provenance Detail page displays only the provenance's name/title. On NewCantus, this page displays a list of sources that have this provenance.
- Several of the APIs from OldCantus are not implemented in NewCantus, or are implemented differently:
- json-activity (accessed via https://cantus.uwaterloo.ca/json-activity and https://cantus.uwaterloo.ca/json-activity?all) is not implemented in NewCantus ([Discussion](https://github.com/DDMAL/CantusDB/issues/126))
- json-analysis-export (accessed, we think, via [https://cantus.uwaterloo.ca/json-analysis-export/?src=\<source id\>](https://cantus.uwaterloo.ca/json-analysis-export/?src=123591)) is not implemented in NewCantus ([Discussion](https://github.com/DDMAL/CantusDB/issues/124))
- some of the keys in the json generated by json-node (accessed via [https://cantus.uwaterloo.ca/json-node/\<id\>](https://cantus.uwaterloo.ca/json-node/123591)) are different in NewCantus ([Discussion](https://github.com/DDMAL/CantusDB/issues/106))
- in the csv API, if the source in question has only sequences and no chants, OldCantus outputs a csv file with only a header and no rows. In this situation, NewCantus outputs a list of all the sequences in the source using the same headers as for chant sources.
- in the csv API,
- if the source in question has only sequences and no chants, OldCantus outputs a csv file with only a header and no rows. In this situation, NewCantus outputs a list of all the sequences in the source using the same headers as for chant sources.
- OldCantus has a `cao_concordances` column. We were asked not to display chants' CAO concordances anywhere, so this column has been left out. (see [issue 125](https://github.com/DDMAL/CantusDB/issues/125))
- all people are represented as Users in NewCantus. This is in contrast to OldCantus, where there were two separate lists of people: one of Indexers and one of Users. ([Discussion](https://github.com/DDMAL/CantusDB/issues/218))

#### Logged-In Users
Expand Down
6 changes: 6 additions & 0 deletions django/cantusdb_project/align_text_mel.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ def syllabize_text(text, pre_syllabized=False):


def syllabize_melody(volpiano):
# there exist several chants in the database whose volpiano is just `\n` -
# if a chant essentially has no volpiano, bail out early.
volpiano = volpiano.strip()
if not volpiano:
return []

# the clef in volpiano should be 1--- with three dashes, if missing any dash, insert it
if volpiano[1] != "-":
volpiano = volpiano[:1] + "-" + volpiano[1:]
Expand Down
5 changes: 4 additions & 1 deletion django/cantusdb_project/articles/templates/article_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ <h4>
<a href="{% url 'article-detail' article.id %}">{{ article.title }}</a>
</h4>
<div class="container">
{{ article.body|safe|truncatechars_html:3000 }}
<small>
{{ article.body.html|safe|truncatechars_html:3000 }}
</small>
</div>
</div>
</div>
{% endfor %}
{% include "pagination.html" %}
<br>
</div>
{% endblock %}
8 changes: 6 additions & 2 deletions django/cantusdb_project/articles/tests/test_articles.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
from django.test import TestCase
from django.urls import reverse
from articles.models import Article
from faker import Faker
from main_app.tests.make_fakes import (
make_fake_text,
make_fake_user,
)

# run with `python -Wa manage.py test articles.tests.test_articles`
# the -Wa flag tells Python to display deprecation warnings

# Create a Faker instance with locale set to Latin
faker = Faker("la")


def make_fake_article(user=None):
if user is None:
user = make_fake_user()
article = Article.objects.create(
title=make_fake_text(max_size=12),
# updated to use Faker (previously called method from make_fakes that no longer exists)
title=faker.sentence(),
author=make_fake_user(),
)
return article
Expand Down
8 changes: 6 additions & 2 deletions django/cantusdb_project/articles/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from django.urls import path
from articles.views import ArticleDetailView
from articles.views import ArticleListView
from articles.views import (
ArticleDetailView,
ArticleListView,
article_list_redirect_from_old_path,
)

urlpatterns = [
path("articles/", ArticleListView.as_view(), name="article-list"),
path("article/<int:pk>", ArticleDetailView.as_view(), name="article-detail"),
path("news/", article_list_redirect_from_old_path),
]
9 changes: 7 additions & 2 deletions django/cantusdb_project/articles/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.urls.base import reverse
from django.views.generic import DetailView, ListView
from articles.models import Article

Expand All @@ -12,6 +13,10 @@ class ArticleDetailView(DetailView):
class ArticleListView(ListView):
model = Article
queryset = Article.objects.order_by("-date_created")
paginate_by = 100
paginate_by = 10
context_object_name = "articles"
template_name = "article_list.html"


def article_list_redirect_from_old_path(request):
return redirect(reverse("article-list"))
30 changes: 28 additions & 2 deletions django/cantusdb_project/cantusdb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,34 @@
# https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-auto-created-primary-keys
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "email-smtp.us-west-2.amazonaws.com"
EMAIL_PORT = 587
EMAIL_HOST_USER = os.getenv("AWS_EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("AWS_EMAIL_HOST_PASSWORD")
EMAIL_USE_TLS = True

DEFAULT_FROM_EMAIL = "noreply@cantusdatabase.simssa.ca"

# automatically disable all panels which user can then manually enable
DEBUG_TOOLBAR_CONFIG = {
"DISABLE_PANELS": {
"debug_toolbar.panels.history.HistoryPanel",
"debug_toolbar.panels.versions.VersionsPanel",
"debug_toolbar.panels.timer.TimerPanel",
"debug_toolbar.panels.settings.SettingsPanel",
"debug_toolbar.panels.headers.HeadersPanel",
"debug_toolbar.panels.request.RequestPanel",
"debug_toolbar.panels.sql.SQLPanel",
"debug_toolbar.panels.staticfiles.StaticFilesPanel",
"debug_toolbar.panels.templates.TemplatesPanel",
"debug_toolbar.panels.cache.CachePanel",
"debug_toolbar.panels.signals.SignalsPanel",
"debug_toolbar.panels.logging.LoggingPanel",
"debug_toolbar.panels.redirects.RedirectsPanel",
"debug_toolbar.panels.profiling.ProfilingPanel",
},
}

INTERNAL_IPS = [
"127.0.0.1",
Expand Down
54 changes: 43 additions & 11 deletions django/cantusdb_project/main_app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ def __init__(self, *args, **kwargs):
"""


class NameModelChoiceField(forms.ModelChoiceField):
"""
A custom ModelChoiceField that overrides the label_from_instance method
to display the object's name attribute instead of str(object).
This field is specifically designed for handling genre and office objects.
Rather than displaying the name along with its description, sometimes we
only want the shorthand notation for the genre and office objects.
(Eg. [AV] Antiphon verse --> AV)
"""

def label_from_instance(self, obj):
return obj.name


# 3 best
class ChantCreateForm(forms.ModelForm):
class Meta:
Expand Down Expand Up @@ -115,13 +129,19 @@ class Meta:
help_text="Each folio starts with '1'.",
)

office = forms.ModelChoiceField(
queryset=Office.objects.all().order_by("name"), required=False
# We use NameModelChoiceField here so the dropdown list of office/mass displays the name
# instead of [name] + description
office = NameModelChoiceField(
queryset=Office.objects.all().order_by("name"),
required=False,
)
office.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})

genre = forms.ModelChoiceField(
queryset=Genre.objects.all().order_by("name"), required=False
# We use NameModelChoiceField here so the dropdown list of genres displays the name
# instead of [name] + description
genre = NameModelChoiceField(
queryset=Genre.objects.all().order_by("name"),
required=False,
)
genre.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})

Expand Down Expand Up @@ -329,13 +349,19 @@ class Meta:
)
feast.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})

office = forms.ModelChoiceField(
queryset=Office.objects.all().order_by("name"), required=False
# We use NameModelChoiceField here so the dropdown list of office/mass displays the name
# instead of [name] + description
office = NameModelChoiceField(
queryset=Office.objects.all().order_by("name"),
required=False,
)
office.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})

genre = forms.ModelChoiceField(
queryset=Genre.objects.all().order_by("name"), required=False
# We use NameModelChoiceField here so the dropdown list of genres displays the name
# instead of [name] + description
genre = NameModelChoiceField(
queryset=Genre.objects.all().order_by("name"),
required=False,
)
genre.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})

Expand Down Expand Up @@ -430,13 +456,17 @@ class Meta:
)
feast.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})

office = forms.ModelChoiceField(
# We use NameModelChoiceField here so the dropdown list of office/mass displays the name
# instead of [name] + description
office = NameModelChoiceField(
queryset=Office.objects.all().order_by("name"),
required=False,
)
office.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})

genre = forms.ModelChoiceField(
# We use NameModelChoiceField here so the dropdown list of genres displays the name
# instead of [name] + description
genre = NameModelChoiceField(
queryset=Genre.objects.all().order_by("name"), required=False
)
genre.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})
Expand Down Expand Up @@ -594,7 +624,9 @@ class Meta:
"image_link": TextInputWidget(),
}

genre = forms.ModelChoiceField(
# We use NameModelChoiceField here so the dropdown list of genres displays the name
# instead of [name] + description
genre = NameModelChoiceField(
queryset=Genre.objects.all().order_by("name"), required=False
)
genre.widget.attrs.update({"class": "form-control custom-select custom-select-sm"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import csv
from django.contrib.auth.models import Group
from main_app.models import Source, Chant
import string
import secrets

ALPHABET: str = string.ascii_letters + string.digits


class Command(BaseCommand):
Expand All @@ -28,10 +32,16 @@ def handle(self, *args, **kwargs):
if created:
user.first_name = name
user.last_name = surname
full_name: str = " ".join((name, surname))
user.full_name = full_name

user.institution = institution
user.city = city
user.country = country
user.set_password("cantusdb")

password: str = "".join(secrets.choice(ALPHABET) for _ in range(32))
user.set_password(password)

user.save()

if user.groups.first() is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ def get_new_indexer(indexer_id):
full_name=indexer_full_name,
# assign random email to dummy users
email=f"{faker.lexify('????????')}@fakeemail.com",
# leave the password empty for dummy users
# the password can't be empty in login form, so they can't log in
password="",
old_indexer_id=indexer_id,
is_indexer=True,
)
).set_unusable_password() # Set unusable password so the user can't log in or access reset password page


class Command(BaseCommand):
Expand Down
5 changes: 5 additions & 0 deletions django/cantusdb_project/main_app/models/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class Source(BaseModel):
get_user_model(), related_name="sources_user_can_edit", blank=True
)

######
# The following five fields have nothing to do with user permissions,
# instead they give credit to users who are indexers and are displayed
# on the user detail page as sources the user has contributed to.
inventoried_by = models.ManyToManyField(
get_user_model(), related_name="inventoried_sources", blank=True
)
Expand All @@ -90,6 +94,7 @@ class Source(BaseModel):
other_editors = models.ManyToManyField(
get_user_model(), related_name="edited_sources", blank=True
)
######

segment = models.ForeignKey(
"Segment", on_delete=models.PROTECT, blank=True, null=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h3>{{ century.name }}</h3>
<ul>
{% for source in sources|dictsort:"title" %}
<li>
<a href="{% url 'source-detail' source.id %}">
<a href="{% url 'source-detail' source.id %}" title="{{ source.siglum }}">
{{ source.title }}
</a>
</li>
Expand Down
10 changes: 4 additions & 6 deletions django/cantusdb_project/main_app/templates/chant_create.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,11 @@ <h3>Create Chant</h3>
{{ form.melody_id }}
</div>

<div class="form-row align-items-top">
<div class="form-group m-1 col-lg">
<small>{{ form.addendum.label_tag }}</small>
{{ form.addendum }}
</div>
<div class="form-group m-1 col-lg">
<small>{{ form.addendum.label_tag }}</small>
{{ form.addendum }}
</div>

</div>

<div class="form-row align-items-end">
Expand Down