Skip to content

Commit

Permalink
Fix of breadcrumbs, add hydrate org events/groups, populate args
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Dec 19, 2024
1 parent a888f2c commit 76a72d1
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 34 deletions.
28 changes: 24 additions & 4 deletions backend/backend/management/commands/populate_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument("--orgs-per-user", type=int, default=1)
parser.add_argument("--groups-per-org", type=int, default=1)
parser.add_argument("--events-per-org", type=int, default=1)
parser.add_argument("--resources-per-entity", type=int, default=1)
parser.add_argument("--faq-entries-per-entity", type=int, default=1)

def handle(self, *args: str, **options: Unpack[Options]) -> None:
num_users = options["users"]
num_orgs_per_user = options["orgs_per_user"]
num_groups_per_org = options["groups_per_org"]
num_events_per_org = options["events_per_org"]
num_resources_per_entity = options["resources_per_entity"]
num_faq_entries_per_entity = options["faq_entries_per_entity"]

# Clear all tables before creating new data.
UserModel.objects.exclude(username="admin").delete()
Expand Down Expand Up @@ -77,7 +81,7 @@ def handle(self, *args: str, **options: Unpack[Options]) -> None:
created_by=user,
)

org_texts = OrganizationTextFactory(iso="wt", primary=True)
org_texts = OrganizationTextFactory(iso="en", primary=True)

user_org = OrganizationFactory(
created_by=user,
Expand All @@ -100,12 +104,28 @@ def handle(self, *args: str, **options: Unpack[Options]) -> None:
name=f"{user_topic.name} Group",
)

num_orgs = num_users * num_orgs_per_user
num_groups = num_users * num_orgs_per_user * num_groups_per_org
num_events = num_users * num_orgs_per_user * num_events_per_org
num_resources = num_users * (
num_orgs_per_user
+ num_orgs_per_user * num_events_per_org * num_resources_per_entity
+ num_orgs_per_user * num_groups_per_org * num_resources_per_entity
)
num_faq_entries = num_users * (
num_orgs_per_user
+ num_orgs_per_user * num_events_per_org * num_faq_entries_per_entity
+ num_orgs_per_user * num_groups_per_org * num_faq_entries_per_entity
)

self.stdout.write(
self.style.ERROR(
f"Number of users created: {num_users}\n"
f"Number of organizations created: {num_users * num_orgs_per_user}\n"
f"Number of groups created: {num_users * num_orgs_per_user * num_groups_per_org}\n"
f"Number of events created: {num_users * num_orgs_per_user * num_events_per_org}\n"
f"Number of organizations created: {num_orgs}\n"
f"Number of groups created: {num_groups}\n"
f"Number of events created: {num_events}\n"
f"Number of resources created: {num_resources}\n"
f"Number of FAQ entries created: {num_faq_entries}\n"
)
)

Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ services:
python manage.py loaddata fixtures/superuser.json &&
python manage.py loaddata fixtures/status_types.json &&
python manage.py loaddata fixtures/topics.json &&
python manage.py populate_db --users 10 --orgs-per-user 1 --groups-per-org 1 --events-per-org 1 &&
python manage.py populate_db \
--users 10 \
--orgs-per-user 1 \
--groups-per-org 1 \
--events-per-org 1 \
--resources-per-entity 1 \
--faq-entries-per-entity 1 &&
python manage.py runserver 0.0.0.0:${BACKEND_PORT}"
ports:
- "${BACKEND_PORT}:${BACKEND_PORT}"
Expand Down
42 changes: 24 additions & 18 deletions frontend/components/card/search-result/CardSearchResult.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
}"
:src="imageUrl"
:alt="
$t('components.card_search_result.organization_img_alt_text') +
$t('components.card_search_result.group_img_alt_text') +
' ' +
group.organization.name
group.name
"
/>
<div
Expand Down Expand Up @@ -180,11 +180,11 @@
<div
class="flex justify-center space-x-3 md:justify-start lg:space-x-4"
>
<MetaTagOrganization
<!-- <MetaTagOrganization
v-for="(o, i) in organizations"
:key="i"
:organization="o"
/>
/> -->
<!-- <MetaTagMembers
:members="members"
label="components.card_search_result.members"
Expand All @@ -207,7 +207,11 @@
<p v-if="group">@{{ group.groupName }}</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"
class="justify-center md:justify-start md:px-0 md:py-0"
:class="{
'line-clamp-3': isReduced,
'line-clamp-4 lg:line-clamp-5': !isReduced,
}"
>
{{ description }}
</p>
Expand Down Expand Up @@ -235,6 +239,8 @@ const props = defineProps<{
isPrivate?: boolean;
}>();
console.log(`Props: ${JSON.stringify(props, null, 2)}`);
const aboveMediumBP = useBreakpoint("md");
const i18n = useI18n();
Expand Down Expand Up @@ -298,8 +304,8 @@ const eventType = computed<"action" | "learn">(() => {
const imageUrl = computed<string>(() => {
if (props.organization && props.organization.iconUrl) {
return props.organization.iconUrl;
} else if (props.group && props.group.organization.iconUrl) {
return props.group.organization.iconUrl;
} else if (props.group && props.group.iconUrl) {
return props.group.iconUrl;
} else if (props.event && props.event.iconUrl) {
return props.event.iconUrl;
} else if (props.user && props.user.iconUrl) {
Expand Down Expand Up @@ -359,17 +365,17 @@ const onlineLocation = computed<string>(() => {
}
});
const organizations = computed<Organization[]>(() => {
if (props.group) {
return [props.group.organization];
} else if (props.event) {
return props.event.organizations;
} else if (props.resource) {
return [props.resource.organization];
} else {
return [];
}
});
// const organizations = computed<Organization[]>(() => {
// if (props.group) {
// return [props.group.organization];
// } else if (props.event) {
// return props.event.organizations;
// } else if (props.resource) {
// return [props.resource.organization];
// } else {
// return [];
// }
// });
// const stars = computed<number>(() => {
// if (props.resource && props.resource.starers) {
Expand Down
7 changes: 4 additions & 3 deletions frontend/components/page/PageBreadcrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ let organization: Organization;
let group: Group;
let event: Event;
// Note: UUID Regex: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
const organizationRegex =
/^(http:\/\/localhost:\d+|https?:\/\/[\w.-]+)(\/[a-z]{2})?\/organizations\/[0-9a-fA-F-]+(\/about)?$/;
/^(http:\/\/localhost:\d+|https?:\/\/[\w.-]+)(\/[a-z]{2})?\/organizations\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}.+$/;
const groupRegex =
/^(http:\/\/localhost:\d+|https?:\/\/[\w.-]+)(\/[a-z]{2})?\/organizations\/[0-9a-fA-F-]+\/groups\/([0-9a-fA-F-]+)(\/about)?$/;
/^(http:\/\/localhost:\d+|https?:\/\/[\w.-]+)(\/[a-z]{2})?\/organizations\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/groups\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}).+$/;
const eventRegex =
/^(http:\/\/localhost:\d+|https?:\/\/[\w.-]+)(\/[a-z]{2})?\/events\/([0-9a-fA-F-]+)(\/about)?$/;
/^(http:\/\/localhost:\d+|https?:\/\/[\w.-]+)(\/[a-z]{2})?\/events\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}).+$/;
if (organizationRegex.test(url)) {
pageType = "organization";
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 @@ -146,6 +146,7 @@
"components.card_search_result.navigate_to_organization_aria_label": "Navigate to the page for this organization",
"components.card_search_result.navigate_to_resource_aria_label": "Navigate to the page for this resource",
"components.card_search_result.navigate_to_user_aria_label": "Navigate to the page for this user",
"components.card_search_result.group_img_alt_text": "The group logo of",
"components.card_search_result.organization_img_alt_text": "The organization logo of",
"components.card_search_result.supporters_lower": "supporters",
"components.card_search_result.view_video": "View video",
Expand Down
8 changes: 2 additions & 6 deletions frontend/pages/organizations/[id]/events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
organization.name + ' ' + $t('pages.organizations._global.events_lower')
"
:tagline="$t('pages.organizations._global.events_tagline')"
:underDevelopment="true"
>
<div class="flex space-x-2 lg:space-x-3">
<BtnRouteInternal
Expand All @@ -28,9 +27,9 @@
/>
</div>
</HeaderAppPage>
<div v-if="orgEvents.length > 0" class="space-y-3 py-4">
<div v-if="organization.events?.length > 0" class="space-y-3 py-4">
<CardSearchResultEvent
v-for="(u, i) in orgEvents"
v-for="(u, i) in organization.events"
:key="i"
:isReduced="true"
:event="u"
Expand All @@ -41,7 +40,6 @@
</template>

<script setup lang="ts">
import type { Event } from "~/types/events/event";
import { IconMap } from "~/types/icon-map";
const idParam = useRoute().params.id;
Expand All @@ -51,6 +49,4 @@ const organizationStore = useOrganizationStore();
await organizationStore.fetchById(id);
const { organization } = organizationStore;
const orgEvents: Event[] = [];
</script>
3 changes: 1 addition & 2 deletions frontend/pages/organizations/[id]/groups/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
$t('pages.organizations.groups.index.groups_lower')
"
:tagline="$t('pages.organizations.groups.index.tagline')"
:underDevelopment="true"
>
<div class="flex space-x-2 lg:space-x-3">
<BtnRouteInternal
Expand All @@ -30,7 +29,7 @@
/>
</div>
</HeaderAppPage>
<div v-if="organization.groups" class="space-y-3 py-4">
<div v-if="organization.groups?.length > 0" class="space-y-3 py-4">
<CardSearchResultGroup
v-for="(g, i) in organization.groups"
:key="i"
Expand Down
5 changes: 5 additions & 0 deletions frontend/stores/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const useOrganizationStore = defineStore("organization", {
socialLinks: [""],
status: 1,
creationDate: "",

groups: [],
events: [],

organizationTextId: "",
texts: {
Expand Down Expand Up @@ -118,6 +120,7 @@ export const useOrganizationStore = defineStore("organization", {
this.organization.texts = organization.texts;

this.organization.groups = organization.groups;
this.organization.events = organization.events;
}

this.loading = false;
Expand Down Expand Up @@ -152,7 +155,9 @@ export const useOrganizationStore = defineStore("organization", {
socialLinks: org.socialLinks,
status: org.status,
creationDate: org.creationDate,

groups: org.groups,
events: org.events,

organizationTextId: org.texts.orgId,
texts: org.texts,
Expand Down

0 comments on commit 76a72d1

Please sign in to comment.