Skip to content

Commit

Permalink
Rename show_in_list to is_indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
jwang44 committed Sep 20, 2022
1 parent 28720e9 commit 68a6129
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def handle(self, *args, **options):
indexers = Indexer.objects.all()

for user in users:
# set all users to be hidden first
# set all users to be non-indexer first
# those listed as indexers on old Cantus will have this adjusted to True
user.show_in_list = False
user.is_indexer = False
# do not use the existing "name" property,
# because for some reason, the first/last names can have trailing spaces
# TODO: populate the full_name field and remove the "name" property
Expand All @@ -38,7 +38,7 @@ def handle(self, *args, **options):
# keep the user as it is (merge the indexer into existing user)
# and store the ID of its indexer object
homonymous_user.old_indexer_id = indexer.id
homonymous_user.show_in_list = True
homonymous_user.is_indexer = True
homonymous_user.save()
# if the indexer doesn't exist as a user
else:
Expand All @@ -54,5 +54,5 @@ def handle(self, *args, **options):
# the password can't be empty in login form, so they can't log in
password="",
old_indexer_id = indexer.id,
show_in_list=True,
is_indexer=True,
)
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_new_indexer(indexer_id):
# keep the user as it is (merge the indexer into existing user)
# and store the ID of its indexer object
homonymous_user.old_indexer_id = indexer_id
homonymous_user.show_in_list = True
homonymous_user.is_indexer = True
homonymous_user.save()
# if the indexer doesn't exist as a user
else:
Expand All @@ -69,7 +69,7 @@ def get_new_indexer(indexer_id):
# the password can't be empty in login form, so they can't log in
password="",
old_indexer_id = indexer_id,
show_in_list=True,
is_indexer=True,
)


Expand Down
4 changes: 2 additions & 2 deletions django/cantusdb_project/main_app/tests/make_fakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ def make_fake_genre() -> Genre:
return genre


def make_fake_user(show_in_list=True) -> get_user_model():
def make_fake_user(is_indexer=True) -> get_user_model():
"""Generates a fake User object."""
user = get_user_model().objects.create(
full_name=f"{faker.first_name()} {faker.last_name()}",
institution=faker.company(),
city=faker.city(),
country=faker.country(),
show_in_list=show_in_list,
is_indexer=is_indexer,
email=f"{faker.lexify('????????')}@fakeemail.com",
)
return user
Expand Down
2 changes: 1 addition & 1 deletion django/cantusdb_project/main_app/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class IndexerListView(SearchableListMixin, ListView):

def get_queryset(self):
all_users = super().get_queryset()
indexers = all_users.filter(show_in_list=True)
indexers = all_users.filter(is_indexer=True)
display_unpublished = self.request.user.is_authenticated
if display_unpublished:
indexers = indexers.annotate(
Expand Down
7 changes: 4 additions & 3 deletions django/cantusdb_project/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ class User(AbstractUser):
email = models.EmailField(unique=True)
# will be used to check if the user has changed the password assigned to them
changed_initial_password = models.BooleanField(default=False)
# whether to display the user in the user-list page
show_in_list = models.BooleanField(default=False)
# if the user has a associated indexer object on old Cantus, save its ID
# whether the user has an associated indexer object on old Cantus
# if True, list the user in indexer-list page
is_indexer = models.BooleanField(default=False)
# if the user has an associated indexer object on old Cantus, save its ID
old_indexer_id = models.IntegerField(blank=True, null=True)

USERNAME_FIELD = 'email'
Expand Down

0 comments on commit 68a6129

Please sign in to comment.