Skip to content

Commit

Permalink
Update db population, remove test entities, continue hydration
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Oct 13, 2024
1 parent 07f589b commit 313a770
Show file tree
Hide file tree
Showing 40 changed files with 288 additions and 314 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/pr_maintainer_checklist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ jobs:
### Maintainer checklist
- [ ] The commit messages for the remote branch should be checked to make sure the contributor's email is set up correctly so that they receive credit for their contribution
- The contributor's name and icon in remote commits should be the same as what appears in the PR
- If there's a mismatch, the contributor needs to make sure that the [email they use for GitHub](https://github.com/settings/emails) matches what they have for `git config user.email` in their local activist repo
- [ ] The TypeScript and formatting workflows within the [PR checks](https://github.com/activist-org/activist/pull/${{ github.event.pull_request.number }}/checks) do not indicate new errors in the files changed
- [ ] The Playwright end to end and Zap penetration tests have been ran and are passing (if necessary)
- [ ] The [CHANGELOG](https://github.com/activist-org/activist/blob/main/CHANGELOG.md) has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)
- name: First PR Contributor Email Check
id: first_interaction
uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-message: |
## First PR Commit Check
- [ ] The commit messages for the remote branch of a new contributor should be checked to make sure their email is set up correctly so that they receive credit for their contribution
- The contributor's name and icon in remote commits should be the same as what appears in the PR
- If there's a mismatch, the contributor needs to make sure that the [email they use for GitHub](https://github.com/settings/emails) matches what they have for `git config user.email` in their local activist repo
13 changes: 10 additions & 3 deletions backend/backend/management/commands/populate_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from entities.factories import (
GroupFactory,
GroupTextFactory,
OrganizationEventFactory,
OrganizationFactory,
OrganizationTextFactory,
)
Expand Down Expand Up @@ -60,16 +61,18 @@ def handle(self, *args: str, **options: Unpack[Options]) -> None:

for o in range(num_orgs_per_user):
user_org = OrganizationFactory(
name=f"{user_topic.name} Organization (U{u}:O{o})",
org_name=f"organization_{u}_{o}",
name=f"{user_topic.name} Organization",
created_by=user,
)

OrganizationTextFactory(org_id=user_org, iso="wt", primary=True)

for g in range(num_groups_per_org):
user_org_group = GroupFactory(
group_name=f"group_{u}_{o}_{g}",
org_id=user_org,
name=f"{user_topic.name} Group (U{u}:O{o}:G{g})",
name=f"{user_topic.name} Group",
created_by=user,
)

Expand All @@ -79,7 +82,7 @@ def handle(self, *args: str, **options: Unpack[Options]) -> None:

for e in range(num_events_per_org):
user_org_event = EventFactory(
name=f"{user_topic.name} Event (U{u}:O{o}:E{e})",
name=f"{user_topic.name} Event {o}:{e}",
type=random.choice(["learn", "action"]),
created_by=user,
)
Expand All @@ -88,6 +91,10 @@ def handle(self, *args: str, **options: Unpack[Options]) -> None:
event_id=user_org_event, iso="en", primary=True
)

OrganizationEventFactory(
org_id=user_org, event_id=user_org_event
)

self.stdout.write(
self.style.ERROR(
f"Number of users created: {num_users}\n"
Expand Down
2 changes: 2 additions & 0 deletions backend/entities/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Organization,
OrganizationApplication,
OrganizationEvent,
OrganizationGroup,
OrganizationImage,
OrganizationMember,
OrganizationResource,
Expand All @@ -36,6 +37,7 @@

admin.site.register(OrganizationApplication)
admin.site.register(OrganizationEvent)
admin.site.register(OrganizationGroup)
admin.site.register(OrganizationImage)
admin.site.register(OrganizationMember)
admin.site.register(OrganizationResource)
Expand Down
10 changes: 10 additions & 0 deletions backend/entities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

class Organization(models.Model):
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
org_name = models.CharField(max_length=255)
name = models.CharField(max_length=255)
tagline = models.CharField(max_length=255, blank=True)
icon_url = models.OneToOneField(
Expand Down Expand Up @@ -55,6 +56,7 @@ def __str__(self) -> str:

class Group(models.Model):
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
group_name = models.CharField(max_length=255)
name = models.CharField(max_length=255)
tagline = models.CharField(max_length=255, blank=True)
org_id = models.ForeignKey(Organization, on_delete=models.CASCADE)
Expand Down Expand Up @@ -176,6 +178,14 @@ def __str__(self) -> str:
return f"{self.id}"


class OrganizationGroup(models.Model):
org_id = models.ForeignKey(Organization, on_delete=models.CASCADE)
group_id = models.ForeignKey(Group, on_delete=models.CASCADE)

def __str__(self) -> str:
return f"{self.id}"


class OrganizationImage(models.Model):
org_id = models.ForeignKey(Organization, on_delete=models.CASCADE)
image_id = models.ForeignKey("content.Image", on_delete=models.CASCADE)
Expand Down
16 changes: 15 additions & 1 deletion backend/entities/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from rest_framework import serializers

from events.serializers import EventSerializer

from .models import (
Group,
GroupEvent,
Expand All @@ -17,6 +19,7 @@
Organization,
OrganizationApplication,
OrganizationEvent,
OrganizationGroup,
OrganizationImage,
OrganizationMember,
OrganizationResource,
Expand Down Expand Up @@ -59,6 +62,7 @@ class Meta:

fields = [
"id",
"org_name",
"name",
"tagline",
"icon_url",
Expand Down Expand Up @@ -149,9 +153,19 @@ class Meta:


class OrganizationEventSerializer(serializers.ModelSerializer[OrganizationEvent]):
events = EventSerializer(source="event_id", read_only=True) # many=True removed

class Meta:
model = OrganizationEvent
fields = "__all__"
fields = ["org_id", "events"]


class OrganizationGroupSerializer(serializers.ModelSerializer[OrganizationGroup]):
groups = GroupSerializer(source="group_id", read_only=True) # many=True removed

class Meta:
model = OrganizationEvent
fields = ["org_id", "groups"]


class OrganizationMemberSerializer(serializers.ModelSerializer[OrganizationMember]):
Expand Down
1 change: 1 addition & 0 deletions backend/entities/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

router.register(r"organization_applications", views.OrganizationApplicationViewSet)
router.register(r"organization_events", views.OrganizationEventViewSet)
router.register(r"organization_groups", views.OrganizationGroupViewSet)
router.register(r"organization_images", views.OrganizationImageViewSet)
router.register(r"organization_members", views.OrganizationMemberViewSet)
router.register(r"organization_resources", views.OrganizationResourceViewSet)
Expand Down
44 changes: 44 additions & 0 deletions backend/entities/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Organization,
OrganizationApplication,
OrganizationEvent,
OrganizationGroup,
OrganizationImage,
OrganizationMember,
OrganizationResource,
Expand All @@ -39,6 +40,7 @@
GroupTopicSerializer,
OrganizationApplicationSerializer,
OrganizationEventSerializer,
OrganizationGroupSerializer,
OrganizationImageSerializer,
OrganizationMemberSerializer,
OrganizationResourceSerializer,
Expand Down Expand Up @@ -270,6 +272,48 @@ class OrganizationEventViewSet(viewsets.ModelViewSet[OrganizationEvent]):
serializer_class = OrganizationEventSerializer
pagination_class = CustomPagination

def get_queryset(self):
if org_id := self.request.query_params.get("org_id", None):
return self.queryset.filter(org_id=org_id)

return self.queryset

def list(self, request: Request, *args: str, **kwargs: int) -> Response:
queryset = self.get_queryset()
page = self.paginate_queryset(queryset)
if page is not None:
serializer = self.get_serializer(page, many=True)

return self.get_paginated_response(serializer.data)

serializer = self.get_serializer(queryset, many=True)

return Response(serializer.data, status=status.HTTP_200_OK)


class OrganizationGroupViewSet(viewsets.ModelViewSet[OrganizationGroup]):
queryset = OrganizationGroup.objects.all()
serializer_class = OrganizationGroupSerializer
pagination_class = CustomPagination

def get_queryset(self):
if org_id := self.request.query_params.get("org_id", None):
return self.queryset.filter(org_id=org_id)

return self.queryset

def list(self, request: Request, *args: str, **kwargs: int) -> Response:
queryset = self.get_queryset()
page = self.paginate_queryset(queryset)
if page is not None:
serializer = self.get_serializer(page, many=True)

return self.get_paginated_response(serializer.data)

serializer = self.get_serializer(queryset, many=True)

return Response(serializer.data, status=status.HTTP_200_OK)


class OrganizationMemberViewSet(viewsets.ModelViewSet[OrganizationMember]):
queryset = OrganizationMember.objects.all()
Expand Down
1 change: 1 addition & 0 deletions frontend/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* https://activist.org/ 200
1 change: 1 addition & 0 deletions frontend/components/card/about/CardAboutOrganization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
:description="organization.description"
:getInvolved="organization.getInvolved"
:getInvolvedURL="organization.getInvolvedURL"
:isOpen="modalIsOpen"
/>
</div>
<div class="flex-col space-y-3">
Expand Down
13 changes: 6 additions & 7 deletions frontend/components/card/search-result/CardSearchResult.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div
class="card-style flex flex-col justify-center px-3 py-4 md:grow md:flex-row md:justify-start md:py-3 lg:px-5"
>
<!-- MARK: fds -->
<div class="relative flex w-full flex-col md:flex-row">
<div class="flex w-full justify-center md:w-fit">
<NuxtLink
Expand Down Expand Up @@ -106,13 +107,7 @@
</div>
</a>
</div>
<div
class="flex-col pt-3 md:grow md:pl-4 md:pt-0 lg:pl-6"
:class="{
'space-y-2': isReduced,
'space-y-3 md:space-y-4': !isReduced,
}"
>
<div class="flex-col space-y-2 pt-3 md:grow md:pl-4 md:pt-0 lg:pl-6">
<div class="flex flex-col justify-between md:flex-row">
<div class="flex items-center justify-center space-x-2 md:space-x-4">
<NuxtLink
Expand Down Expand Up @@ -210,6 +205,10 @@
<!-- <div v-if="!isReduced" class="flex justify-center md:justify-start">
<ShieldTopic v-for="(t, i) in topics" :key="i" :topic="t" />
</div> -->
<div v-if="organization || group">
<p v-if="organization">@{{ organization.org_name }}</p>
<p v-if="group">@{{ group.group_name }}</p>
</div>
<p
class="line-clamp-4 justify-center md:line-clamp-4 md:justify-start md:px-0 md:py-0 lg:line-clamp-5"
>
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/modal/ModalBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const closeModal = () => {
};
// Check if the user is navigating to another resource.
// If a modal exists, close close it.
// If a modal exists, close it.
watch(route, () => {
if (modals.modals[modalName]) {
closeModal();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<template>
<ModalBase :modalName="modalName">
<ModalBase
@closeModal="handleCloseModal"
:isOpen="modalIsOpen"
:modalName="modalName"
>
<div class="flex flex-col space-y-7">
<div class="flex flex-col space-y-3 text-light-text dark:text-dark-text">
<label for="textarea" class="responsive-h2">{{
Expand Down Expand Up @@ -48,6 +52,10 @@
<script setup lang="ts">
import type { OrganizationUpdateTextFormData } from "~/types/entities/organization";
const props = defineProps<{
isOpen: boolean;
}>();
const idParam = useRoute().params.id;
const id = typeof idParam === "string" ? idParam : undefined;
Expand Down Expand Up @@ -78,5 +86,15 @@ async function handleSubmit() {
}
}
const modals = useModals();
const modalName = "ModalEditAboutOrganization";
let modalIsOpen = computed(() => props.isOpen);
onMounted(() => {
modalIsOpen = computed(() => modals.modals[modalName].isOpen);
});
const handleCloseModal = () => {
modals.closeModal(modalName);
};
</script>
3 changes: 0 additions & 3 deletions frontend/components/page/preview/PagePreviewEvent.vue

This file was deleted.

3 changes: 2 additions & 1 deletion frontend/components/sidebar/left/SidebarLeftIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
>
<Icon :name="IconMap.PLUS" size="1em" />
</button>
<ModalUploadImages @closeModal="handleCloseModal" :uploadLimit="1" />
<!-- Attn: Disabled -->
<!-- <ModalUploadImages @closeModal="handleCloseModal" :uploadLimit="1" /> -->
<ImageOrganization
class="elem-shadow-sm"
:imgURL="logoUrl"
Expand Down
1 change: 1 addition & 0 deletions frontend/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@
"pages.organizations._global.faq_tagline": "Questions we often get",
"pages.organizations._global.resources_tagline": "Useful links and tools for our work",
"pages.organizations.affiliates.affiliates_lower": "affiliates",
"pages.organizations.affiliates.tagline": "Who we support",
"pages.organizations.create.complete_application": "Complete application",
"pages.organizations.create.description_placeholder": "Please provide a description of the organization for the community so that we can learn more about its goals and composition",
"pages.organizations.create.header": "Application information",
Expand Down
2 changes: 1 addition & 1 deletion frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default defineNuxtConfig({
},
i18n: {
lazy: true,
strategy: "prefix_and_default",
strategy: "prefix",
langDir: "./i18n",
vueI18n: "./i18n.config.ts",
baseUrl: "https://activist.org",
Expand Down
3 changes: 0 additions & 3 deletions frontend/pages/events/[id]/about.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@
<script setup lang="ts">
import { BreakpointMap } from "~/types/breakpoint-map";
import { IconMap } from "~/types/icon-map";
import { testClimateEvent } from "~/utils/testEntities";
const event = testClimateEvent;
const textExpanded = ref(false);
const expandReduceText = () => {
Expand Down
3 changes: 0 additions & 3 deletions frontend/pages/events/[id]/discussion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
<script setup lang="ts">
import useBreakpoint from "~/composables/useBreakpoint";
import { IconMap } from "~/types/icon-map";
import { testClimateEvent } from "~/utils/testEntities";
const aboveMediumBP = useBreakpoint("md");
const event = testClimateEvent;
</script>
3 changes: 0 additions & 3 deletions frontend/pages/events/[id]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@
import { BreakpointMap } from "~/types/breakpoint-map";
import { IconMap } from "~/types/icon-map";
import type { MenuSelector } from "~/types/menu/menu-selector";
import { testClimateEvent } from "~/utils/testEntities";
import useMenuEntriesState from "~/composables/useMenuEntriesState";
const event = testClimateEvent;
const { id } = useRoute().params;
const localPath = useLocalePath();
Expand Down
Loading

0 comments on commit 313a770

Please sign in to comment.