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

Add CLDT to admin domains #2536

Merged
merged 4 commits into from
Sep 27, 2023
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
5 changes: 5 additions & 0 deletions amy/autoemails/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ def check(task: Task): # type: ignore
and task.event.administrator
and task.event.administrator.domain != "self-organized"
and task.event.administrator.domain != "carpentries.org"
# 2023-09-20: also exclude CLDT
and task.event.administrator.domain != "carpentries.org/community-lessons/"
)

def get_additional_context(self, objects, *args, **kwargs):
Expand Down Expand Up @@ -357,6 +359,7 @@ def check(task: Task): # type: ignore
and task.event.administrator
and task.event.administrator.domain != "self-organized"
and task.event.administrator.domain != "carpentries.org"
and task.event.administrator.domain != "carpentries.org/community-lessons/"
)

def get_additional_context(self, objects, *args, **kwargs):
Expand Down Expand Up @@ -488,6 +491,8 @@ def check(event: Event): # type: ignore
# Instructor Training
and event.administrator
and event.administrator.domain != "carpentries.org"
# 2023-09-20: also exclude CLDT
and event.administrator.domain != "carpentries.org/community-lessons/"
elichad marked this conversation as resolved.
Show resolved Hide resolved
)

def get_additional_context(self, objects, *args, **kwargs):
Expand Down
30 changes: 30 additions & 0 deletions amy/fiscal/tests/test_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,33 @@ def test_symmetrical_affiliations(self):
# Assert
self.assertIn(self.org_beta, self.org_alpha.affiliated_organizations.all())
self.assertIn(self.org_alpha, self.org_beta.affiliated_organizations.all())

def test_manager_administrators(self):
"""Ensure the correct organizations are returned as possible administrators."""
# Arrange - `setUp()` also creates 2 organisations these filters should ignore
self._setUpAdministrators()
expected_domains = [
"self-organized",
"software-carpentry.org",
"datacarpentry.org",
"librarycarpentry.org",
# Instructor Training organisation
"carpentries.org",
# Collaborative Lesson Development Training organisation
"carpentries.org/community-lessons/",
]

# Act
organizations_with_admin_domain = Organization.objects.filter(
domain__in=expected_domains
)
administrators = Organization.objects.administrators()

# Assert
# check that all ADMIN_DOMAINS are represented
self.assertSetEqual(
set(expected_domains), set(Organization.objects.ADMIN_DOMAINS)
)
self.assertEqual(organizations_with_admin_domain.count(), len(expected_domains))
# check that administrators() returns what we expect
self.assertQuerysetEqual(organizations_with_admin_domain, administrators)
5 changes: 4 additions & 1 deletion amy/workshops/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ class OrganizationManager(models.Manager):
"software-carpentry.org",
"datacarpentry.org",
"librarycarpentry.org",
"carpentries.org", # Instructor Training organisation
# Instructor Training organisation
"carpentries.org",
# Collaborative Lesson Development Training organisation
"carpentries.org/community-lessons/",
elichad marked this conversation as resolved.
Show resolved Hide resolved
]

def administrators(self):
Expand Down
23 changes: 23 additions & 0 deletions amy/workshops/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,29 @@ def _setUpCommunityRoles(self) -> None:
award=Award.objects.get(person=self.ron, badge=self.instructor_badge),
)

def _setUpAdministrators(self) -> None:
"""Adds administrator organizations to the database."""
Organization.objects.bulk_create(
[
Organization(domain="self-organized", fullname="Self-Organized"),
Organization(
domain="software-carpentry.org",
fullname="Software Carpentry",
),
Organization(domain="datacarpentry.org", fullname="Data Carpentry"),
Organization(
domain="librarycarpentry.org",
fullname="Library Carpentry",
),
Organization(domain="carpentries.org", fullname="Instructor Training"),
Organization(
domain="carpentries.org/community-lessons/",
fullname="Collaborative Lesson Development Training",
),
],
ignore_conflicts=True,
)

@staticmethod
def reconsent(person: Person, term: Term, term_option: TermOption) -> Consent:
consent = Consent.objects.get(
Expand Down
4 changes: 2 additions & 2 deletions docs/amy_database_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The primary tables used in AMY (that will appear in most queries) are those that
* `assigned_to_id` The id of the Regional Coordinator or other Carpentries Core Team member assigned to this event. This is linked to the `workshops_person` table.
* `language_id` The integer id of the language used at the workshop. This is not typically recorded. This is linked to the `workshops_language` table
* `open_TTT_applications` Used only for instructor training events
* `adminstrator_id` An integer representing the event organizer. This is linked to the `workshops_organization` table. Historically any organization could be listed as an administrator. Recent updates to AMY limit this to Data Carpentry, Library Carpentry, Software Carpentry, The Carpentries, or self-organized. This enforcement is at the AMY app level, not at the database level.
* `adminstrator_id` An integer representing the event organizer. This is linked to the `workshops_organization` table. Historically any organization could be listed as an administrator. Recent updates to AMY limit this to Data Carpentry, Library Carpentry, Software Carpentry, Instructor Training, Collaborative Lesson Development Training, or self-organized. This enforcement is at the AMY app level, not at the database level.
* `reg_key` Eventbrite registration key
* `instructors_pre` Link to both pre- and post-workshop survey results.

Expand Down Expand Up @@ -293,4 +293,4 @@ When training request consents are archived, a new unset consent is created by A
* `training_request_id` id of the training request this consent option belongs to. This is linked to the `workshops_trainingrequest` table.
* `term_id` id of the term this consent applies to. This is linked to the `consents_term` table. There is a check on the Consent model to ensure the given TermOption belongs to the Term.
* `term_option_id` id of the term option chosen in this consent. This is linked to the `consents_termoption` table. When this field is null, the consent has not been set by the user.
* `archived_at` a timestamp of when the consent was archived or `NULL` if it wasn't.
* `archived_at` a timestamp of when the consent was archived or `NULL` if it wasn't.
4 changes: 2 additions & 2 deletions docs/users_guide/admin_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Go to the [New Event](https://amy.carpentries.org/workshops/events/add/) page by

* **Membership** Select the Membership this event should be applied to, by membership term and membership dates.

* **Administrator** Select the administrator from the drop down menu. This will always be `Data Carpentry`, `Library Carpentry`, `Software Carpentry`, `Instructor Training`, or `Self-Organised`.
* **Administrator** Select the administrator from the drop down menu. This will always be `Data Carpentry`, `Library Carpentry`, `Software Carpentry`, `Instructor Training`, `Collaborative Lesson Development Training` or `Self-Organised`.

* **Is this workshop public** If the workshop Host consents, choose "Public." This will list the workshop on the websites for The Carpentries, the associated lesson programs, and The Carpentries data feeds. If "Private" it will not be listed publicly anywhere.

Expand Down Expand Up @@ -608,7 +608,7 @@ Clicking "Events" on the top menu bar will take you to a list of *all* recorded
* **Assigned to**: The admin user the event is assigned to
* **Tags**: Any tags applied to that event
* **Host**: The organisation hosting the event
* **Administrator** The event administrator (A lesson program for centrally organised workshops, self organised, or Instructor Training)
* **Administrator** The event administrator (A lesson program for centrally organised workshops, self organised, Instructor Training, or Collaborative Lesson Development Training)
* **Completed** Whether the "completed" box has been checked, indicating all necessary work for that event is complete
* **Country** Country from the event's location
* **Continent** Continent based on the country
Expand Down
Loading