from Events.Engine.abstract_class import PageInfo from .bases import Components, KeyTypes, ValidationRequest, icon, cluster_name from .bases import KeyValidations, KeyBases, PageBases, KeyURLs from .account_records import ( AccountRecordsUpdateEventMethods, AccountRecordsCreateEventMethods, AccountRecordsListEventMethods, ) from .lang_models import ( account_language_list_models_as_dict, account_language_create_form_models_as_dict, account_language_update_form_models_as_dict, account_language_create_link_models_as_dict, account_language_update_link_models_as_dict, ) RedisValidation = dict( NAME="AccountCluster", PREFIX="/accounts", URL="/dashboard?site=AccountCluster", ICON="Building", INFO={ "en": { "page": "Account Records for reaching user all types account information", }, "tr": { "page": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıtları", }, }, SUB_COMPONENTS={ "/accounts/create": { "SITE_URL": "/events/create?site=AccountCluster", "COMPONENT": "Link", "PREFIX_URL": "/accounts/create", "INFO": { "en": { "page": "Create Account Records", "actions": "Actions", "table": "Table", }, "tr": { "page": "Hesap Kayıdı Oluştur", "actions": "Aksiyonlar", "table": "Tablo", }, }, "INSTRUCTIONS": None, }, "/accounts/list": { "SITE_URL": "/events/dashboard?site=AccountCluster", "COMPONENT": "Table", "PREFIX_URL": "/accounts/list", "INFO": { "en": { "page": "List Account Records" }, "tr": { "page": "Hesap Kayıtlarını Listele" }, }, "INSTRUCTIONS": { "headers": { "store": True, "url": "/validations/header", "data": { "event_code": "/accounts/list", "asked_field": "headers", }, }, "data": { "store": True, "url": "/accounts/list", "data": { "page": 1, "limit": 1, "order_by": "uu_id", "order_type": "desc", "query": None, }, }, }, }, }, ) class ClustersPageInfo: # Cluster Page Infos that are available for the client dashboard_page_info = PageInfo( name=f"{cluster_name}", url=PageBases.DASHBOARD, icon=icon, info={ "en": { "page": "Account Records for reaching user all types account information", }, "tr": { "page": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıtları", }, }, sub_components={ str(KeyBases.create_key): { "SITE_URL": PageBases.CREATE, "COMPONENT": Components.LINK, "PREFIX_URL": KeyBases.create_key, "ENDPOINTS": AccountRecordsCreateEventMethods.retrieve_all_event_keys(), "LANGUAGE_MODELS": account_language_create_link_models_as_dict, "INSTRUCTIONS": {}, }, str(KeyBases.update_key): { "SITE_URL": PageBases.UPDATE, "COMPONENT": Components.LINK, "PREFIX_URL": KeyBases.update_key, "ENDPOINTS": AccountRecordsUpdateEventMethods.retrieve_all_event_keys(), "LANGUAGE_MODELS": account_language_update_link_models_as_dict, "INSTRUCTIONS": {}, }, str(KeyBases.list_key): { "SITE_URL": PageBases.DASHBOARD, "COMPONENT": Components.TABLE, "PREFIX_URL": KeyBases.list_key, "INFO": { "en": {"page": "List Account Records"}, "tr": {"page": "Hesap Kayıtlarını Listele"}, }, "ENDPOINTS": AccountRecordsListEventMethods.retrieve_all_event_keys(), "LANGUAGE_MODELS": account_language_list_models_as_dict, "INSTRUCTIONS": { "HEADERS": { "store": True, "url": KeyURLs.validations, "data": ValidationRequest( event_code=f"{KeyBases.list_key}", asked_field=KeyValidations.headers, type=KeyTypes.RESPONSE ).dump(), }, "DATA": { "store": True, "url": f"{KeyBases.list_key}", "params": None, "data": dict(page=1, limit=1, order_by="uu_id", order_type="desc", query=None), }, }, }, }, ) create_page_info = PageInfo( name=f"{cluster_name}", url=PageBases.CREATE, icon=icon, info={ "en": { "page": "Create Account Records for reaching user all types account information", }, "tr": { "page": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıt Oluştur", }, }, sub_components={ str(KeyBases.create_key): { "SITE_URL": PageBases.CREATE, "COMPONENT": Components.FORM, "PREFIX_URL": KeyBases.create_key, "INFO": { "en": {"page": "Create Account Records", "button": "Create"}, "tr": {"page": "Hesap Kayıtlarını Oluştur", "button": "Oluştur"}, }, "ENDPOINTS": AccountRecordsCreateEventMethods.retrieve_all_event_keys(), "LANGUAGE_MODELS": account_language_create_form_models_as_dict, "INSTRUCTIONS": { "VALIDATION": { "store": True, "url": KeyURLs.validations, "data": ValidationRequest( event_code=f"{KeyBases.create_key}", asked_field=KeyValidations.validation, type=KeyTypes.REQUEST ).dump(), }, "HEADERS": { "store": True, "url": KeyURLs.validations, "data": ValidationRequest( event_code=f"{KeyBases.create_key}", asked_field=KeyValidations.headers, type=KeyTypes.REQUEST ).dump(), }, }, }, }, ) update_page_info = PageInfo( name=f"{cluster_name}", url=PageBases.UPDATE, icon=icon, info={ "en": { "page": "Update Account Records via all types account information", }, "tr": { "page": "Tüm hesap bilgileri aracılığıyla Hesap Kayıtlarını Güncelle", }, }, sub_components={ str(KeyBases.update_key): { "SITE_URL": PageBases.UPDATE, "COMPONENT": Components.FORM, "PREFIX_URL": KeyBases.update_key, "INFO": { "en": {"page": "Update Account Records", "button": "Update"}, "tr": {"page": "Hesap Kayıtlarını Güncelle", "button": "Güncelle"}, }, "ENDPOINTS": AccountRecordsUpdateEventMethods.retrieve_all_event_keys(), "LANGUAGE_MODELS": account_language_update_form_models_as_dict, "INSTRUCTIONS": { "VALIDATION": { "store": True, "url": KeyURLs.validations, "data": ValidationRequest( event_code=f"{KeyBases.update_key}", asked_field=KeyValidations.validation, type=KeyTypes.REQUEST ).dump(), }, "HEADERS": { "store": True, "url": KeyURLs.validations, "data": ValidationRequest( event_code=f"{KeyBases.update_key}", asked_field=KeyValidations.headers, type=KeyTypes.REQUEST ).dump(), }, "DATA": { "store": True, "url": f"{KeyBases.list_key}", "params": {"uu_id": "SomeUUID"}, "data": dict(page=1, size=1, limit=1, order_by="uu_id", order_type="desc", query={"uu_id": "SomeUUID"}), }, }, }, }, ) # Page Variations of the cluster page_infos = { ClustersPageInfo.dashboard_page_info.URL: ClustersPageInfo.dashboard_page_info, ClustersPageInfo.create_page_info.URL: ClustersPageInfo.create_page_info, ClustersPageInfo.update_page_info.URL: ClustersPageInfo.update_page_info, } # Check if all the page info is implemented in the mappings for t in [x for k, x in PageBases.__dict__.items() if not str(k).startswith("__")]: if t not in list(dict(page_infos).keys()): raise NotImplementedError(f"Page Info of : {t} is not implemented in mappings")