269 lines
10 KiB
Python
269 lines
10 KiB
Python
from Events.Engine.abstract_class import PageInfo
|
||
from Events.base_request_model import AUTH_URL_EXTENSION, EVENTS_URL_EXTENSION, VALID_URL_EXTENSION
|
||
from .account_records import (
|
||
AccountRecordsUpdateEventMethods,
|
||
AccountRecordsCreateEventMethods,
|
||
AccountRecordsListEventMethods,
|
||
)
|
||
from .bases import Components, KeyTypeValidations, KeyTypes, ValidationRequest, icon, cluster_name
|
||
from .bases import KeyValidations, KeyBases, PageBases, KeyURLs
|
||
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 = PageInfo(
|
||
name=f"{cluster_name}",
|
||
url=PageBases.DASHBOARD,
|
||
icon=icon,
|
||
template_ui="LCU",
|
||
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": {
|
||
KeyTypeValidations.HEADERS: {
|
||
"store": True,
|
||
"url": f"{VALID_URL_EXTENSION}{KeyURLs.validations}",
|
||
"data": ValidationRequest(
|
||
event_code=f"{KeyBases.list_key}",
|
||
asked_field=KeyValidations.headers,
|
||
type_=KeyTypes.RESPONSE
|
||
).dump(),
|
||
},
|
||
KeyTypeValidations.DATA: {
|
||
"store": True,
|
||
"url": f"{EVENTS_URL_EXTENSION}{KeyBases.list_key}",
|
||
"params": None,
|
||
"data": dict(page=1, limit=1, order_by="uu_id", order_type="desc", query=None),
|
||
},
|
||
},
|
||
},
|
||
},
|
||
)
|
||
|
||
CREATE = PageInfo(
|
||
name=f"{cluster_name}",
|
||
url=PageBases.CREATE,
|
||
icon=icon,
|
||
template_ui="LCU",
|
||
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": {
|
||
KeyTypeValidations.VALIDATION: {
|
||
"store": True,
|
||
"url": f"{VALID_URL_EXTENSION}{KeyURLs.validations}",
|
||
"data": ValidationRequest(
|
||
event_code=f"{KeyBases.create_key}",
|
||
asked_field=KeyValidations.validation,
|
||
type_=KeyTypes.REQUEST
|
||
).dump(),
|
||
},
|
||
KeyTypeValidations.HEADERS: {
|
||
"store": True,
|
||
"url": f"{VALID_URL_EXTENSION}{KeyURLs.validations}",
|
||
"data": ValidationRequest(
|
||
event_code=f"{KeyBases.create_key}",
|
||
asked_field=KeyValidations.headers,
|
||
type_=KeyTypes.REQUEST
|
||
).dump(),
|
||
},
|
||
KeyTypeValidations.MODIFY: {
|
||
"store": False,
|
||
"url": f"{EVENTS_URL_EXTENSION}{KeyBases.create_key}",
|
||
"params": None,
|
||
"data": None,
|
||
},
|
||
},
|
||
},
|
||
},
|
||
)
|
||
|
||
UPDATE = PageInfo(
|
||
name=f"{cluster_name}",
|
||
url=PageBases.UPDATE,
|
||
icon=icon,
|
||
template_ui="LCU",
|
||
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": {
|
||
KeyTypeValidations.VALIDATION: {
|
||
"store": True,
|
||
"url": f"{VALID_URL_EXTENSION}{KeyURLs.validations}",
|
||
"data": ValidationRequest(
|
||
event_code=f"{KeyBases.update_key}",
|
||
asked_field=KeyValidations.validation,
|
||
type_=KeyTypes.REQUEST
|
||
).dump(),
|
||
},
|
||
KeyTypeValidations.HEADERS: {
|
||
"store": True,
|
||
"url": f"{VALID_URL_EXTENSION}{KeyURLs.validations}",
|
||
"data": ValidationRequest(
|
||
event_code=f"{KeyBases.update_key}",
|
||
asked_field=KeyValidations.headers,
|
||
type_=KeyTypes.REQUEST
|
||
).dump(),
|
||
},
|
||
KeyTypeValidations.MODIFY: {
|
||
"store": False,
|
||
"url": f"{EVENTS_URL_EXTENSION}{KeyBases.update_key}",
|
||
"params": None,
|
||
"data": None,
|
||
},
|
||
},
|
||
},
|
||
},
|
||
)
|
||
|
||
# Page Variations of the cluster
|
||
page_infos = {
|
||
ClustersPageInfo.DASHBOARD.URL: ClustersPageInfo.DASHBOARD,
|
||
ClustersPageInfo.CREATE.URL: ClustersPageInfo.CREATE,
|
||
ClustersPageInfo.UPDATE.URL: ClustersPageInfo.UPDATE,
|
||
}
|
||
|
||
|
||
# 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")
|