def process_form(self, wtf, **kwargs): key = wtf.s_key.data.strip() if key == "new": return msg.err('Product key/sku cannot be "new".') if not key: return msg.err('Picture key/sku name is required.') result = database.upsert_product(key, wtf) return result
def read_user(user_id): try: user = models.User.objects.get(id=user_id) except db.DoesNotExist: return msg.err("Account {} not found.".format(user_id)) except db.MultipleObjectsReturned: return msg.err("Duplicate IDs found.") return user
def process_form(self, wtf, **kwargs): key = wtf.s_key.data.strip() if key == "new": return msg.err('Picture key cannot be "new".') if not key: return msg.err('Picture key name is required.') details = s3_upload(wtf.file) result = database.upsert_articlePicture(key, wtf, details) return result
def delete_article(key): try: a = models.Article.objects.get(s_key=key) a.delete() update_articleList_universal() except db.DoesNotExist: return msg.err("could not find {}".format(key)) return a
def process(self, table_name=None, **kwargs): self.tables = [] for table_class in self.table_order: self.tables.append(table_class()) if self.tables: self.default_table_name = self.tables[0].key_name else: self.status = msg.err("no tables in report") return if not table_name: table_name = self.default_table_name self.table_name = table_name self.status = msg.err("table name [{}] not found".format(table_name)) for table in self.tables: if table.key_name == table_name: self.display_table = table self.status = table.process_report_table(**kwargs)
def create_article(key, wtf): if not _good_key_check(key): return msg.err("{} is not a valid group/page combination.".format(key)) article = models.Article() article.s_key = key article.s_title = wtf.s_title.data article.s_creole_text = wtf.s_creole_text.data article.dt_last_update = datetime.datetime.now() article.tf_blog = wtf.blog.tf_blog.data article.s_blogger_name = wtf.blog.s_blogger_name.data article.dt_blog_date = wtf.blog.dt_blog_date.data article.s_byline = wtf.blog.s_byline.data article.s_img_key = wtf.blog.s_img_key.data article.arr_blog_categories = _parse_cats(wtf.blog.categories.data) # # all is good. Save everything. # _save_article(article) return article
def process(self, TABLE_NAME=None, **kwargs): self.url_params = kwargs # # PROCESS TABLES # if self.has_tables: self.current_table_name = None self.tables = [] for table_class in self.table_order: self.tables.append(table_class(outer_page_instance=self)) self.default_table_name = self.tables[0].key_name if not TABLE_NAME: TABLE_NAME = self.default_table_name self.table_name = TABLE_NAME self.status = msg.err("table name [{}] not found".format( self.table_name)) self.skip_table_body = True for table in self.tables: if table.key_name == self.table_name: self.display_table = table self.status = table.process_table( ** kwargs) # should we add TABLE_NAME to start of params? if not isinstance(self.status, EmptyTable): self.skip_table_body = False # # PROCESS CATALOG # if self.has_catalog: self.catalog = self.MainCatalog(self) self.catalog.process_catalog(TABLE_NAME=TABLE_NAME, **kwargs) # # PROCESS MAIN FORM # if self.has_form: # fondum_utility.handle_form_imports(self.MainForm) self.wtf = self.MainForm(outer_page_instance=self, style=self.form_style) # self.status = msg.success("page processed")
def __init__(self): self.status = msg.err("report not processed")
def read_user_byOAuth(email, authid, source): try: user = models.User.objects.get(s_oauth_email=email, s_oauth_id=authid, s_oauth_source=source) except db.DoesNotExist: user = msg.err("Account does not exist.") return user
def delete_product(key): product = read_product(key) if msg.is_bad(product): return msg.err("Product {} missing; possibly already deleted.".format(key)) product.delete() return msg.success("Product {} deleted.".format(product.s_key))
def read_testDocument(doc_id): doc = TestDocument.objects(id=doc_id).first() if doc: return doc return msg.err("Unable to locate document")
def __init__(self): self.status = msg.err("report not processed") self.display_table = None self.table_name = None self.default_table_name = None
def read_account_byUser(user): try: account = models.Account.objects.get(ref_user=user.id) except db.DoesNotExist: return msg.err("Cannot find account {}".format(user.id)) return account