class AltNameSchema(Schema): if_key_missing = None Delete = validators.Bool() Culture = ciocvalidators.ActiveCulture(record_cultures=True) AltName = ciocvalidators.UnicodeString(max=200) New = validators.Bool()
class ListStreetType(ListValuesModel): Table = "GBL_StreetType" FieldCode = "st" AdminAreaCode = "STREETTYPE" NameField = "StreetType" ID = "SType_ID" ListName = _("Street Type") ListNamePlural = _("street types") ExtraFields = [ { "type": "language", "title": _("Language"), "field": "Culture", "kwargs": {}, "validator": validators.ActiveCulture(record_cultures=True), }, { "type": "checkbox", "title": _("Display After Street"), "field": "AfterName", "kwargs": {}, "validator": validators.Bool(), "element_title": _("Street Type displays after the Street Name: "), }, ]
class ReminderBaseSchema(validators.Schema): if_key_missing = None ActiveDate = validators.DateConverter() Culture = validators.ActiveCulture(record_cultures=True) DueDate = validators.DateConverter() NoteTypeID = validators.IDValidator() Notes = validators.UnicodeString(not_empty=True) DismissForAll = validators.DictConverter(dismiss_options, not_empty=True)
class DomainSchema(Schema): if_key_missing = None DMAP_ID = validators.IDValidator(not_empty=True) DefaultCulture = validators.ActiveCulture(not_empty=True) CICViewType = validators.IDValidator() VOLViewType = validators.IDValidator() SecondaryName = validators.Bool() GoogleMapsAPIKeyCIC = validators.String(max=100) GoogleMapsClientIDCIC = validators.UnicodeString(max=100) GoogleMapsChannelCIC = validators.UnicodeString(max=100) GoogleMapsAPIKeyVOL = validators.String(max=100) GoogleMapsClientIDVOL = validators.UnicodeString(max=100) GoogleMapsChannelVOL = validators.UnicodeString(max=100)
class ListContactPhoneType(ListValuesModel): Table = "GBL_Contact_PhoneType" FieldCode = "cpt" ID = None id_validator = validators.UnicodeString(max=20) AdminAreaCode = "PHONETYPE" NameField = "PhoneType" ListName = _("Contact Phone Type") ListNamePlural = _("phone types") ExtraFields = [ { "type": "language", "title": _("Language"), "field": "Culture", "kwargs": {}, "validator": validators.ActiveCulture(record_cultures=True), }, ] HasModified = False
def __init__(self, request, require_login=True): ViewBase.__init__(self, request, require_login) domain_validator = validators.DictConverter( { str(const.DMT_CIC.id): const.DMT_CIC, str(const.DMT_VOL.id): const.DMT_VOL }, if_invalid=None, if_empty=None, ) ShowCultures = All( validators.Set(use_set=True), ForEach(ciocvalidators.ActiveCulture(record_cultures=True)), if_invalid=None, if_empty=None, ) ShowCulturesOnlyActive = All( validators.Set(use_set=True), ForEach(ciocvalidators.ActiveCulture(record_cultures=False)), if_invalid=None, if_empty=None, ) def cull_extra_cultures(desc_key, multi_key=None, ensure_active_cultures=True,
def save(self): request = self.request user = request.user domain = self.get_domain() if request.params.get("Delete"): query = [("PageID", request.params.get("PageID")), ("DM", domain.id)] self._go_to_route("admin_pages", action="delete", _query=query) is_add = request.matchdict.get("action") == "add" model_state = request.model_state extra_validators = {} pageid_validator = {} if is_add: extra_validators["Culture"] = validators.ActiveCulture(not_empty=True) else: pageid_validator["PageID"] = validators.IDValidator(not_empty=True) schema = validators.RootSchema( page=PageSchemaBase(**extra_validators), views=validators.ForEach(validators.IDValidator()), **pageid_validator ) model_state.schema = schema model_state.form.variable_decode = True if model_state.validate(): page_id = model_state.value("PageID") args = [ page_id, user.Mod, request.dboptions.MemberID, domain.id, user.Agency, model_state.value("page.Culture"), model_state.value("page.Slug"), model_state.value("page.Title"), model_state.value("page.Owner"), model_state.value("page.PageContent"), ",".join(map(str, model_state.value("views", []))), ] log.debug("args %s", args) with request.connmgr.get_connection("admin") as conn: sql = """ DECLARE @ErrMsg as nvarchar(500), @RC as int, @PageID as int SET @PageID = ? EXECUTE @RC = dbo.sp_GBL_Page_u @PageID OUTPUT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @ErrMsg=@ErrMsg OUTPUT SELECT @RC as [Return], @ErrMsg AS ErrMsg, @PageID as PageID """ cursor = conn.execute(sql, *args) result = cursor.fetchone() cursor.close() if not result.Return: page_id = result.PageID if is_add: msg = _("The Page was successfully added.", request) else: msg = _("The Page was successfully updated.", request) query = [("InfoMsg", msg), ("PageID", page_id), ("DM", domain.id)] self._go_to_route("admin_pages", action="edit", _query=query) ErrMsg = _("Unable to save: ") + result.ErrMsg else: if model_state.is_error("PageID"): self._error_page(_("Invalid Page ID", request)) page_id = model_state.value("PageID") ErrMsg = _("There were validation errors.") page = None with request.connmgr.get_connection("admin") as conn: cursor = conn.execute( "EXEC dbo.sp_GBL_Page_s ?, ?, ?, ?", request.dboptions.MemberID, user.Agency, domain.id, page_id, ) page = cursor.fetchone() cursor.nextset() views = cursor.fetchall() cursor.close() if not page and not is_add: self._error_page(_("Page Not Found", request)) title = _("Page (%s)", request) % _(domain.label, request) data = model_state.form.data data["views"] = request.POST.getall("views") return self._create_response_namespace( title, title, dict( PageID=page_id, page=page, is_add=is_add, views=views, domain=domain, ErrMsg=ErrMsg, ), no_index=True, )
class CicDetailsSchema(validators.Schema): TmpLn = validators.ActiveCulture(record_cultures=True, if_error=None) InlineResults = validators.Bool() UseCICVwTmp = validators.IDValidator(if_error=None)