-
-
Notifications
You must be signed in to change notification settings - Fork 60
23 create speaker mgmt #172
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
Open
mayakerostasia
wants to merge
8
commits into
pyladies:main
Choose a base branch
from
mayakerostasia:23-create-speaker-mgmt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b98d655
Adding Speakers Application skeleton
mayakerostasia 1cbbfd4
Merge branch 'pyladies:main' into 23-create-speaker-mgmt
mayakerostasia 7ae2469
Merge with home computer
mayakerostasia edd4ba7
xfer to home computer
mayakerostasia df70215
fixing lint errors
1140d72
update ignore to include encrypted env files
1711902
added Events and Load Event Speakers Button when superuser
e3d67bb
Merge branch 'main' into 23-create-speaker-mgmt
Mariatta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ env/ | |
| .env.prod | ||
| .env.prod.db | ||
| .env | ||
| .env.enc | ||
|
|
||
| # Coverage and state | ||
| .coverage | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ services: | |
| DJANGO_DEFAULT_FROM_EMAIL: PyLadiesCon <[email protected]> | ||
| DJANGO_EMAIL_HOST: maildev | ||
| DJANGO_EMAIL_PORT: 1025 | ||
| env_file: .env | ||
| depends_on: | ||
| redis: | ||
| condition: service_healthy | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from django.contrib import admin | ||
|
|
||
| from .models import Event | ||
|
|
||
| class EventAdmin(admin.ModelAdmin): | ||
| list_display = ("event_slug",) | ||
| search_fields = ("event_slug",) | ||
| # list_filter = ("region", "application_status") | ||
|
|
||
| admin.site.register(Event, EventAdmin) |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import os | ||
| import requests | ||
| import json | ||
|
|
||
| class PretalxClient: | ||
| """ A simple client for interacting with Pretalx REST API """ | ||
| def __init__(self, base_url=None, default_headers=None, timeout=10): | ||
| token = os.getenv('PRETALX_API_TOKEN') | ||
| if not token: | ||
| raise ValueError("Please provide an environment Variable named 'PRETALX_API_TOKEN'") | ||
| else: | ||
| self.token = token | ||
|
|
||
| self.session = requests.Session() | ||
|
|
||
| self.base_url = base_url.rstrip('/') if base_url else None | ||
| self.timeout = timeout | ||
|
|
||
| self.default_headers = { | ||
| 'Accept': 'application/json', | ||
| 'Content-Type': 'application/json', | ||
| 'User-Agent': 'Python PretalxClient/1.0' | ||
| } | ||
|
|
||
| if default_headers: | ||
| self.default_headers.update(default_headers) | ||
|
|
||
| self.session.headers.update(self.default_headers) | ||
|
|
||
|
|
||
| def auth(self): | ||
| """ Add Authentication parameters to the Pretalx Client Request """ | ||
| self.session.headers.update({"Authorization": f"Token {self.token}"}) | ||
|
|
||
| def _build_url(self, endpoint: str) -> str: | ||
| url = f"{self.base_url}/{endpoint.lstrip('/')}" if self.base_url else endpoint | ||
| return url | ||
|
|
||
| def get_events(self, event_name: str): | ||
| """ Get a list of events by name search """ | ||
| url = self._build_url("/events") | ||
| query = { | ||
| # "q": event_name | ||
| # "is_public": True | ||
| } | ||
| resp = self.session.get(url, params=query) | ||
| print(resp) | ||
| return resp.text | ||
|
|
||
| def get_event(self, event_slug: str): | ||
| url = self._build_url(f"/events/{event_slug}") | ||
| resp = self.session.get(url) | ||
| print(resp) | ||
| return resp.json() | ||
|
|
||
| def get_speakers(self, event_slug: str): | ||
| # https://pretalx.com/api/events/{event}/speakers/ | ||
| url = self._build_url(f"/events/{event_slug}/speakers") | ||
| resp = self.session.get(url) | ||
| resp.raise_for_status() | ||
| return resp.json() | ||
|
|
||
| def get_speaker_information(self, event_slug: str): | ||
| # https://pretalx.com/api/events/{event}/speaker-information/ | ||
| url = self._build_url(f"/events/{event_slug}/speaker-information") | ||
| resp = self.session.get(url) | ||
| resp.raise_for_status() | ||
| return resp.json() | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from .client import PretalxClient | ||
|
|
||
| PRETALX_BASE_URL="https://pretalx.com/api" | ||
| EVENT_NAME="mayatest1-2025" | ||
|
|
||
| def fetch_event_speakers(event_name: str): | ||
| client = PretalxClient(base_url=PRETALX_BASE_URL) | ||
| client.auth() | ||
| return client.get_speakers(event_name) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Generated by Django 5.1.8 on 2025-05-29 11:33 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| initial = True | ||
|
|
||
| dependencies = [ | ||
| ("portal", "0001_initial"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="Event", | ||
| fields=[ | ||
| ( | ||
| "basemodel_ptr", | ||
| models.OneToOneField( | ||
| auto_created=True, | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| parent_link=True, | ||
| primary_key=True, | ||
| serialize=False, | ||
| to="portal.basemodel", | ||
| ), | ||
| ), | ||
| ("event_slug", models.CharField(blank=True)), | ||
| ], | ||
| bases=("portal.basemodel",), | ||
| ), | ||
| ] |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from django.db import models | ||
|
|
||
| from portal.models import BaseModel | ||
|
|
||
| class Event(BaseModel): | ||
| event_slug = models.CharField(blank=True, null=False) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from django.contrib.auth.decorators import login_required | ||
| from django.urls import path | ||
|
|
||
| from . import views | ||
|
|
||
| app_name = "speaker" | ||
|
|
||
| urlpatterns = [ | ||
| path("", views.index, name="index"), | ||
| path( | ||
| "load-speakers", | ||
| login_required(views.load_speakers), | ||
| name="speaker-load", | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| from django.contrib.auth.decorators import login_required | ||
| from django.shortcuts import render | ||
| from django.http import HttpResponse | ||
|
|
||
| from .models import Event | ||
| from speaker.models import SpeakerProfile | ||
|
|
||
|
|
||
| ### | ||
| # # Fetch Pretalx Speakers | ||
| ### | ||
| from .api.pretalx import fetch_event_speakers | ||
|
|
||
| def pull_event_speakers(event_slug): | ||
| speaker_results = fetch_event_speakers(event_slug) | ||
| print(speaker_results) | ||
| for speaker in speaker_results['results']: | ||
| print(speaker) | ||
| return speaker_results['results'] | ||
|
|
||
| def create_speakers(speakers: list[dict]): | ||
| for speaker in speakers: | ||
| already_created = SpeakerProfile.objects.filter(code__contains=speaker.get('code')) | ||
| if len(already_created) == 0: | ||
| SpeakerProfile.objects.create(**speaker) | ||
| else: | ||
| print("Speaker already Created") | ||
| print(already_created.first()) | ||
|
|
||
| print(SpeakerProfile.objects.count()) | ||
|
|
||
|
|
||
| @login_required | ||
| def index(request): | ||
| context = {} | ||
| event = Event.objects.first() | ||
| if event: | ||
| context["event_slug"] = event.event_slug | ||
| else: | ||
| context["event_slug"] = None | ||
| return render(request, "event/index.html", context) | ||
|
|
||
|
|
||
| @login_required | ||
| def load_speakers(request): | ||
| # context = {} | ||
| events = Event.objects.all() | ||
| for event in events: | ||
| pull_event_speakers(event.event_slug) | ||
| return HttpResponse("") | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| from django.contrib import admin | ||
|
|
||
| class AdminExtension(admin.AdminSite): | ||
| def get_app_list(self, request, app_label=None): | ||
| app_list = super().get_app_list(request, app_label) | ||
| app_list += [ | ||
| { | ||
| "name": "Events/Speaker Management", | ||
| "app_label": "prtlx_mgmt", | ||
| "models": [ | ||
| { | ||
| "name": "event", | ||
| "object_name": "event", | ||
| "admin_url": "/admin/event", | ||
| "view_only": True | ||
| }, | ||
| { | ||
| "name": "speaker", | ||
| "object_name": "speaker", | ||
| "admin_url": "/admin/speaker", | ||
| "view_only": True | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
|
|
||
| return app_list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,8 @@ | |
| "storages", | ||
| "portal", | ||
| "volunteer", | ||
| "speaker", | ||
| "event", | ||
| "portal_account", | ||
| "widget_tweaks", | ||
| ] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from django.contrib import admin | ||
|
|
||
| from .models import SpeakerProfile | ||
|
|
||
| class SpeakerProfileAdmin(admin.ModelAdmin): | ||
| list_display = ("code", "name", "email") | ||
| search_fields = ("code", "name", "email") | ||
| # list_filter = ("region", "application_status") | ||
|
|
||
| admin.site.register(SpeakerProfile, SpeakerProfileAdmin) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class VolunteerConfig(AppConfig): | ||
| default_auto_field = "django.db.models.BigAutoField" | ||
| name = "speaker" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| from enum import StrEnum | ||
|
|
||
|
|
||
| # class RoleTypes(StrEnum): | ||
| # """Role types for the volunteer.""" | ||
|
|
||
| # ADMIN = "Admin" | ||
| # STAFF = "Staff" | ||
| # VENDOR = "Vendor" | ||
| # VOLUNTEER = "Volunteer" | ||
|
|
||
|
|
||
| class ApplicationStatus(StrEnum): | ||
| """Application status for the volunteer.""" | ||
|
|
||
| PENDING = "Pending Review" | ||
| APPROVED = "Approved" | ||
| REJECTED = "Rejected" | ||
| CANCELLED = "Cancelled" | ||
|
|
||
|
|
||
| class Region(StrEnum): | ||
| """Region where the volunteer usually reside.""" | ||
|
|
||
| NO_REGION = "" | ||
| ASIA = "Asia" | ||
| EUROPE = "Europe" | ||
| NORTH_AMERICA = "North America" | ||
| SOUTH_AMERICA = "South America" | ||
| AFRICA = "Africa" | ||
| OCEANIA = "Oceania" |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import re | ||
|
|
||
| from django import forms | ||
| from django.core.exceptions import ValidationError | ||
| from django.forms import ModelForm | ||
| from django.forms.widgets import SelectMultiple | ||
|
|
||
| from .languages import LANGUAGES | ||
| from .models import SpeakerProfile | ||
|
|
||
| class LanguageSelectMultiple(SelectMultiple): | ||
| """ | ||
| A custom widget for selecting multiple languages with autocomplete. | ||
| """ | ||
|
|
||
| def __init__(self, attrs=None, choices=()): | ||
| default_attrs = { | ||
| "class": "form-control select2-multiple", | ||
| "data-placeholder": "Start typing to select languages...", | ||
| } | ||
| if attrs: | ||
| default_attrs.update(attrs) | ||
| super().__init__(default_attrs, choices) | ||
|
|
||
| class SpeakerProfileForm(ModelForm): | ||
|
|
||
| # discord_username = forms.CharField(required=True) | ||
| additional_comments = forms.CharField(widget=forms.Textarea, required=False) | ||
|
|
||
| class Meta: | ||
| model = SpeakerProfile | ||
| exclude = ["application_status"] | ||
| help_texts = { | ||
| # "github_username": "GitHub username (e.g., username)", | ||
| # "discord_username": "Required - Your Discord username for team communication (e.g., username#1234)", | ||
| # "instagram_username": "Instagram username without @ (e.g., username)", | ||
| # "bluesky_username": "Bluesky username (e.g., username or username.bsky.social)", | ||
| # "mastodon_url": "Mastodon handle (e.g., @[email protected] or https://instance.tld/@username)", | ||
| # "x_username": "X/Twitter username without @ (e.g., username)", | ||
| # "linkedin_url": "LinkedIn URL (e.g., linkedin.com/in/username)", | ||
| "region": "Region where you normally reside", | ||
| } | ||
|
|
||
| def clean(self): | ||
| cleaned_data = super().clean() | ||
| return cleaned_data | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| # self.user = kwargs.pop("user", None) | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| sorted_languages = sorted(LANGUAGES, key=lambda x: x[1]) | ||
|
|
||
| self.fields["discord_username"].required = True | ||
| self.fields["languages_spoken"].choices = sorted_languages | ||
| self.fields["languages_spoken"].widget = LanguageSelectMultiple( | ||
| choices=sorted_languages | ||
| ) | ||
|
|
||
| if self.instance and self.instance.pk: | ||
| pass | ||
|
|
||
| def save(self, commit=True): | ||
| # if self.user: | ||
| # self.instance.user = self.user | ||
| volunteer_profile = super().save(commit) | ||
| return volunteer_profile |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VolunteerConfig needs renamed