Skip to content

feat: added admin filtering and tracking added for all admin related functionality#13

Open
thevoid12 wants to merge 4 commits intoPandaWhoCodes:masterfrom
thevoid12:admin-tracking
Open

feat: added admin filtering and tracking added for all admin related functionality#13
thevoid12 wants to merge 4 commits intoPandaWhoCodes:masterfrom
thevoid12:admin-tracking

Conversation

@thevoid12
Copy link
Copy Markdown
Contributor

Issue resolved: No admin tracking #7
issue:
Add admin filtering and API enhancements

Description
This PR adds admin-level data filtering for events, event_fields, message_templates, and qr_codes, along with moving hardcoded Clerk JWKS URL to environment variable.

Changes:

  • Admin filtering for all resources (events, fields, templates, QR codes) which involves schema changes and api level changes.
  • Clerk JWKS URL was hardcoded in the code which is now moved to CLERK_JWKS_URL env var
  • Updated database schema and test fixtures

Tests:

  • Ran all tests
  • tested the feature in local environment

Note:
since admin_user_id is a not null field, please delete the existing dev detabase to avoid db migration.

…nd qr_codes along will all the api changes, hardcoded cleark jwks url is moved to env
Copy link
Copy Markdown
Owner

@PandaWhoCodes PandaWhoCodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate all the help.
thanks @thevoid12

give me sometime to confirm everything on my local and see if eveything works.
the last release is already up and running on events.build2learn.in

Comment thread backend/app/api/events.py Outdated
Comment thread backend/app/api/event_fields.py
Comment thread backend/app/core/auth.py
@PandaWhoCodes
Copy link
Copy Markdown
Owner

"""Delete a message template"""
query = "DELETE FROM message_templates WHERE id = ?"
await db.execute(query, [template_id])
query = "DELETE FROM message_templates WHERE id = ? AND admin_user_id = ?"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i should be able to delete any template
not just the templates created by me

SELECT id, template_name, template_text, admin_user_id, created_at, updated_at
FROM message_templates
WHERE id = ?
WHERE id = ? AND admin_user_id = ?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here
i need to get all templates
not just the ones I created
my templates should be accessible to all community admins

SELECT id, template_name, template_text, created_at, updated_at
SELECT id, template_name, template_text, admin_user_id, created_at, updated_at
FROM message_templates
WHERE admin_user_id = ?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to fix

"DELETE FROM event_fields WHERE id = ? AND event_id = ?",
[field_id, event_id]
"DELETE FROM event_fields WHERE id = ? AND event_id = ? AND admin_user_id = ?",
[field_id, event_id, auth.user_id]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this lockin that only I can delete my content.
Can you run through the changes again and fix this across the board
I do not want to be the only person able to edit delete anything
the dashboard can be used across the board of organizers - no hierarchy there

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PandaWhoCodes so any admin can view,edit or delete anything wrt event? I will make these changes then

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes sir
Any - its the same behaviour we see in luma and google forms. We dont have multiple communities. this is a single community instance.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please resolve these comments

Comment thread backend/app/services/event_service.py
@thevoid12
Copy link
Copy Markdown
Contributor Author

@PandaWhoCodes made the changes. Removed the filter so admin dashboard related activities like edits,fetch or delete can be done by any admin!

Comment thread backend/app/services/event_service.py Outdated
event = await db.fetch_one(
"SELECT * FROM events WHERE is_active = 1 ORDER BY created_at DESC LIMIT 1"
async def get_active_event() -> List[EventResponse]:
"""Get all active events for a specific admin"""
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check this code. this documentation is not correct. we dont want to get admin specific tasks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry didnt notice that. pushed the fixed documentation

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to apologize dude

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im grateful for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants