def post(self): c_ID = self.request.get('con_id') _con = Contention.get_by_id(int(c_ID)) branch_name = self.request.get('branch') elem_type = self.request.get('etype') parent_type = self.request.get('ptype') content = self.request.get('content') step = int(self.request.get('step')) + 1 e = Elements(contention_key=_con, g_frame=step) if parent_type == "con": e.top_level = 1 else: e.parent_id = int(self.request.get('pid')) e.content = content e.branch_name = branch_name e.element_type = elem_type logging.info("etype= " + elem_type) e.parent_t = parent_type if self.logged_in: logging.info('Checking currently logged in user') logging.info(self.current_user.name) sessiony = self.auth.get_user_by_session() e.author = self.current_user.name e.author_id = sessiony['user_id'] e.put() _con.g_frames = step _con.put()
def post(self): branch_name = self.request.get('branch_name') edit_type = self.request.get('e_type') premise_type = self.request.get('p_type') logging.info(self.request.POST) picture_url_0 = self.request.get('picture_url_0') if picture_url_0: field_storage = self.request.POST.multi['picture_url_0'] mimetype = field_storage.type logging.info("Mimetype: {}".format(mimetype)) user = self.current_user branch_q = db.GqlQuery("SELECT * FROM Branch WHERE branch = :1", branch_name) branch = branch_q.get() #branch = Branch(parent=branch_key('Business')) #branch_key = branch.Key().id() #b_key = db.Key.from_path('Branch', branch) #tag_list1 = split(self.request.get('form_content_0')) tag_list = ['one', 'two', 'three'] step = 0 if premise_type == "contention": if edit_type == "0": c = Contention(branch_key=branch, tags=tag_list) c.content = self.request.get('form_content_0') c.branch_name = branch_name if self.logged_in: logging.info('Checking currently logged in user') logging.info(self.current_user.name) sessiony = self.auth.get_user_by_session() c.author = self.current_user.name c.author_id = sessiony['user_id'] c.put() if picture_url_0 != '': i = Images(branch_key=branch, contention_key=c) i.image = db.Blob(picture_url_0) i.element_type = "contention" i.description = self.request.get('image_description_0') if self.logged_in: i.author = self.current_user.name i.author_id = sessiony['user_id'] i.put() c.image_id = i.key().id() c.put() elif edit_type == "1": contention_ID = self.request.get('c_id') con = Contention.get_by_id(int(contention_ID)) if con.g_frames: step = con.g_frames else: step = 0 gframe = Elements(contention_key=con, element_type="contention", gframe=step, image_id=con.image_id, author=con.author, author_id=con.author_id, content=con.content) gframe.put() con.content = self.request.get('form_content_0') con.g_frames = step + 1 if picture_url_0 != '': i = Images(branch_key=branch, contention_key=c) i.image = db.Blob(picture_url_0) i.element_type = "contention" i.description = self.request.get('image_description_0') if self.logged_in: sessiony = self.auth.get_user_by_session() i.author = self.current_user.name i.author_id = sessiony['user_id'] i.put() con.image_id = i.key().id() con.put() if premise_type == "element": contention_ID = self.request.get('c_id') con = Contention.get_by_id(int(contention_ID)) if edit_type == "0": c = Elements(contention_key=con, gframe=step) c.content = self.request.get('form_content_0') c.branch_name = branch_name if self.logged_in: logging.info('Checking currently logged in user') logging.info(self.current_user.name) sessiony = self.auth.get_user_by_session() c.author = self.current_user.name c.author_id = sessiony['user_id'] c.put() if picture_url_0 != '': i = Images(branch_key=branch, contention_key=con) i.image = db.Blob(picture_url_0) i.element_type = "contention" i.description = self.request.get('image_description_0') if self.logged_in: i.author = self.current_user.name i.author_id = sessiony['user_id'] i.put() c.image_id = i.key().id() c.put() con.g_frames = step + 1 con.put() elif edit_type == "1": contention_ID = self.request.get('c_id') con = Contention.get_by_id(int(contention_ID)) gframe = Elements(contention_key=con, element_type="contention", gframe=step, image_id=con.image_id, author=con.author, author_id=con.author_id, content=con.content) gframe.put() con.content = self.request.get('form_content_0') con.g_frames = step + 1 if picture_url_0 != '': i = Images(branch_key=branch, contention_key=c) i.image = db.Blob(picture_url_0) i.element_type = "contention" i.description = self.request.get('image_description_0') if self.logged_in: sessiony = self.auth.get_user_by_session() i.author = self.current_user.name i.author_id = sessiony['user_id'] i.put() con.image_id = i.key().id() con.put() reasons = int(self.request.get('_reasons')) objections = int(self.request.get('_objections')) if reasons > 0: if edit_type == "0": for reas in range(1, reasons + 1): pic = 'picture_url_' + str(reas) pict = self.request.get(pic) if premise_type == "contention": r = Elements(contention_key=c, top_level=1, gframe=step) if premise_type == "element": r = Elements(contention_key=con, top_level=0, gframe=step, parent_id=c.key().id()) r.element_type = 'reason' if pict != '': i = Images(branch_key=branch, contention_key=c) i.image = db.Blob(picture_url_0) i.element_type = "contention" i.description = self.request.get('image_description_0') if self.logged_in: sessiony = self.auth.get_user_by_session() i.author = self.current_user.name i.author_id = sessiony['user_id'] i.put() #r.image_id=i.key().id() rcon = 'form_reason_' + str(reas) r.content = self.request.get(rcon) r.branch_name = branch_name if self.logged_in: sessiony = self.auth.get_user_by_session() r.author = self.current_user.name r.author_id = sessiony['user_id'] r.put() elif edit_type == "1": for reas in range(1, reasons + 1): pic = 'picture_url_' + str(reas) pict = self.request.get(pic) el_id = 'form_reason_' + str(reas) + '_' e_id = self.request.get(el_id) rcon = 'form_reason_' + str(reas) r_content = self.request.get(rcon) logging.info("this is test") logging.info('form_reason_' + str(reas) + '_') r = Elements.get_by_id(int(e_id)) if r_content != r.content: if premise_type == "contention": gframe = Elements(contention_key=con, element_type="reason", gframe=step, image_id=r.image_id, author=r.author, author_id=r.author_id, content=r.content) gframe.put() r.content = r_content r.g_frame = con.g_frames if premise_type == "element": r = Elements(contention_key=con, parent_id=c.key().id()) r.top_level = 0 r.element_type = 'reason' if pict != '': i = Images(branch_key=branch, contention_key=c) i.image = db.Blob(picture_url_0) i.element_type = "contention" i.description = self.request.get( 'image_description_0') if self.logged_in: sessiony = self.auth.get_user_by_session() i.author = self.current_user.name i.author_id = sessiony['user_id'] i.put() #r.image_id=i.key().id() rcon = 'form_reason_' + str(reas) r.content = self.request.get(rcon) r.branch_name = branch_name if self.logged_in: sessiony = self.auth.get_user_by_session() r.author = self.current_user.name r.author_id = sessiony['user_id'] r.put() if objections > 0: for objs in range(1, objections + 1): picobjs = objs + 5 pic = 'picture_url_' + str(picobjs) pict = self.request.get(pic) o = Elements(contention_key=c) if premise_type == "contention": o = Elements(contention_key=c) o.top_level = 1 if premise_type == "element": o = Elements(contention_key=con, parent_id=c) o.top_level = 0 if pict != '': o.image = db.Blob(urlfetch.Fetch(pict).content) ocon = 'form_objection_' + str(objs) o.content = self.request.get(ocon) o.branch_name = branch_name if self.logged_in: sessiony = self.auth.get_user_by_session() o.author = self.current_user.name o.author_id = sessiony['user_id'] o.put() self.redirect('/conv?con_id=%s' % c.key().id())