def __init__(self, request: Request): super().__init__(request) self.sub_path = request.matchdict.get('sub_path') self.url = '/'.join(self.sub_path) self.page = cms_service.get_page(self.url) self.redirect = cms_service.get_redirect(self.url) self.redirect_url = None if self.redirect: self.redirect_url = self.redirect.get('url') if request.query_string: self.redirect_url = f'{self.redirect_url}?{request.query_string}'
def process_form(self): d = self.request_dict self.short_url = d.get('short_url') self.url = d.get('url') self.name = d.get('name') self.redirect_id = d.get('redirect_id') if not self.short_url: self.error = "You must specify a short url" if not self.redirect and cms_service.get_redirect(self.short_url): self.error = f"A redirect with url {self.short_url} already exists!" if self.redirect and not cms_service.get_redirect_by_id(self.redirect_id): self.error = f"A redirect with ID {self.redirect_id} was not found!"
def __init__(self, request: Request): super().__init__(request) self.sub_path = request.matchdict.get('sub_path') self.url = '/'.join(self.sub_path) self.page = cms_service.get_page(self.url) self.html = None if self.page: self.html = self.convert_to_markdown(self.page.contents) # self.html = self.convert_to_markdown((self.page.contents + '\n')*20) self.redirect = cms_service.get_redirect(self.url) self.redirect_url = None if self.redirect: self.redirect_url = self.redirect.url if request.query_string: self.redirect_url = f'{self.redirect_url}?{request.query_string}'