From 74b1893aea4458c41bb102caa8e7ca64a7aef583 Mon Sep 17 00:00:00 2001 From: Kiran Jonnalagadda Date: Mon, 30 Oct 2023 11:37:28 +0530 Subject: [PATCH 01/11] Fix base class for account-level notifications (#1916) --- funnel/models/notification_types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/funnel/models/notification_types.py b/funnel/models/notification_types.py index a8fc70102..ca11d5a04 100644 --- a/funnel/models/notification_types.py +++ b/funnel/models/notification_types.py @@ -248,7 +248,7 @@ class RegistrationReceivedNotification( class OrganizationAdminMembershipNotification( - DocumentHasAccount, + DocumentIsAccount, Notification[Account, AccountMembership], type='organization_membership_granted', ): @@ -263,7 +263,7 @@ class OrganizationAdminMembershipNotification( class OrganizationAdminMembershipRevokedNotification( - DocumentHasAccount, + DocumentIsAccount, Notification[Account, AccountMembership], type='organization_membership_revoked', shadows=OrganizationAdminMembershipNotification, From cf2cdca0f516cd60b1c183c2b8ea904215b819bd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 22:41:09 +0530 Subject: [PATCH 02/11] [pre-commit.ci] pre-commit autoupdate (#1917) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.1 → v0.1.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.1...v0.1.3) - [github.com/psf/black: 23.10.0 → 23.10.1](https://github.com/psf/black/compare/23.10.0...23.10.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1221e3fd3..a0c91efbe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -54,7 +54,7 @@ repos: - id: pyupgrade args: ['--keep-runtime-typing', '--py310-plus'] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.1 + rev: v0.1.3 hooks: - id: ruff args: ['--fix', '--exit-non-zero-on-fix'] @@ -100,7 +100,7 @@ repos: additional_dependencies: - tomli - repo: https://github.com/psf/black - rev: 23.10.0 + rev: 23.10.1 hooks: - id: black # Mypy is temporarily disabled until the SQLAlchemy 2.0 migration is complete From 683cf9dea34f808609d25191f98f63bfed924c1f Mon Sep 17 00:00:00 2001 From: Vidya Ramakrishnan Date: Fri, 3 Nov 2023 10:29:37 +0530 Subject: [PATCH 03/11] Usher to have access to ticket event title (#1919) --- funnel/models/sync_ticket.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/funnel/models/sync_ticket.py b/funnel/models/sync_ticket.py index cc717b686..924570375 100644 --- a/funnel/models/sync_ticket.py +++ b/funnel/models/sync_ticket.py @@ -157,6 +157,9 @@ class TicketEvent(GetTitleMixin, Model): 'read': {'name', 'title'}, 'write': {'name', 'title'}, }, + 'project_usher': { + 'read': {'name', 'title'}, + }, } From bdb4a6b4b83379386d6992e12c24275ec47200ed Mon Sep 17 00:00:00 2001 From: anishTP <119032387+anishTP@users.noreply.github.com> Date: Fri, 3 Nov 2023 15:20:37 +0530 Subject: [PATCH 04/11] Rename `user` to `account` in AuthClientPermissionsView (#1920) --- funnel/views/auth_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/funnel/views/auth_client.py b/funnel/views/auth_client.py index d71ce9b87..558d526c2 100644 --- a/funnel/views/auth_client.py +++ b/funnel/views/auth_client.py @@ -297,19 +297,19 @@ def delete(self) -> ReturnView: @AuthClientPermissions.views('main') -@route('/apps/info//perms/u/') +@route('/apps/info//perms/u/') class AuthClientPermissionsView(UrlForView, ModelView): model = AuthClientPermissions route_model_map = {'client': 'auth_client.buid', 'account': 'account.buid'} obj: AuthClientPermissions - def loader(self, client: str, user: str) -> AuthClientPermissions: + def loader(self, client: str, account: str) -> AuthClientPermissions: return ( AuthClientPermissions.query.join( AuthClient, AuthClientPermissions.auth_client ) .join(Account, AuthClientPermissions.account) - .filter(AuthClient.buid == client, Account.buid == user) + .filter(AuthClient.buid == client, Account.buid == account) .one_or_404() ) From 42ebe35c17f0a7c19eefa801aa033831139fc341 Mon Sep 17 00:00:00 2001 From: Kiran Jonnalagadda Date: Fri, 3 Nov 2023 17:14:53 +0530 Subject: [PATCH 05/11] Create member role on Account (#1921) The role is acquired from the temporary hack of a membership-granting project. This is to be soon replaced with AccountMembership gaining new role columns. --- funnel/models/project.py | 9 +++++++ funnel/templates/profile.html.jinja2 | 30 ++++++++++----------- funnel/templates/project_layout.html.jinja2 | 4 +-- funnel/views/profile.py | 9 +++---- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/funnel/models/project.py b/funnel/models/project.py index 5bf0787bc..cdc10ce7b 100644 --- a/funnel/models/project.py +++ b/funnel/models/project.py @@ -89,6 +89,7 @@ class Project(UuidMixin, BaseScopedNameMixin, Model): None: { 'admin': 'account_admin', 'follower': 'account_participant', + 'member': 'account_member', } }, # `account` only appears in the 'primary' dataset. It must not be included in @@ -840,6 +841,14 @@ def published_project_count(self) -> int: self.listed_projects.filter(Project.state.PUBLISHED).order_by(None).count() ) + @with_roles(grants_via={None: {'participant': 'member'}}) + @cached_property + def membership_project(self) -> Project | None: + """Return a project that has memberships flag enabled (temporary).""" + return self.projects.filter( + Project.boxoffice_data.op('@>')({'has_membership': True}) + ).first() + class ProjectRedirect(TimestampMixin, Model): __tablename__ = 'project_redirect' diff --git a/funnel/templates/profile.html.jinja2 b/funnel/templates/profile.html.jinja2 index 4802fe6d9..8bb7b167d 100644 --- a/funnel/templates/profile.html.jinja2 +++ b/funnel/templates/profile.html.jinja2 @@ -145,7 +145,7 @@ {{ featured_section(featured_project) }} {{ upcoming_section(upcoming_projects) }} - {% if has_membership_project %} + {% if membership_project %}
@@ -158,10 +158,10 @@
- {% if has_membership_project.bg_image.url %} - {% trans %}Membership{% endtrans %} + {% if membership_project.bg_image.url %} + {% trans %}Membership{% endtrans %} {% else %} {% trans %}Membership{% endtrans %} @@ -170,23 +170,23 @@
- {% if has_membership_project.bg_image.url %} - {% trans %}Membership{% endtrans %} + {% if membership_project.bg_image.url %} + {% trans %}Membership{% endtrans %} {% else %} {% trans %}Membership{% endtrans %} {% endif %}
-
{{ has_membership_project.description }}
+
{{ membership_project.description }}
-
{{ has_membership_project.description }}
- {% if has_membership_project.current_roles.ticket_participant %} +
{{ membership_project.description }}
+ {% if profile.current_roles.member %}
- {% elif has_membership_project.features.show_tickets %} + {% elif membership_project.features.show_tickets %}