Skip to content

Commit

Permalink
feat: add default menu to newly created community
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullai-t committed Jul 18, 2024
1 parent f46578b commit 08eb3f5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/api/store/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
CommunityMember, CommunityNotificationSetting, ContactUsPageSettings, CustomCommunityWebsiteDomain, \
DonatePageSettings, EventsPageSettings, FeatureFlag, get_enabled_flags, Goal, Graph, HomePageSettings, \
ImpactPageSettings, Location, \
Media, RealEstateUnit, RegisterPageSettings, SigninPageSettings, Subdomain, TeamsPageSettings, \
Media, Menu, RealEstateUnit, RegisterPageSettings, SigninPageSettings, Subdomain, TeamsPageSettings, \
TestimonialsPageSettings, UserProfile, VendorsPageSettings
from database.utils.common import json_loader
from .utils import (get_community, get_community_or_die, get_new_title, get_user_from_context, is_reu_in_community)
Expand Down Expand Up @@ -103,6 +103,23 @@ def check_community_membership(feature_flag, should_enable, community):
else:
feature_flag.communities.add(community)
feature_flag.save()


def create_default_menu(community):
if not community: return None
# load the default menu json
default_menu_json = json_loader("database/raw_data/portal/menu.json")
menu = Menu(
community=community,
name="{} - Default Menu".format(community.subdomain),
is_custom=True,
is_published=True,
content=default_menu_json.get("PortalMainNavLinks", []),
footer_content=default_menu_json.get("PortalFooterLinks", {}),
contact_info=default_menu_json.get("PortalFooterContactInfo", {}),
)
menu.save()



class CommunityStore:
Expand Down Expand Up @@ -760,6 +777,7 @@ def create_community(

# clone everything for this community
homePage = HomePageSettings.objects.filter(is_template=True).first()
create_default_menu(community)
images = homePage.images.all()
# TODO: make a copy of the images instead, then in the home page, you wont have to create new files everytime
if homePage:
Expand Down

0 comments on commit 08eb3f5

Please sign in to comment.