Ejemplo n.º 1
0
 def post(self):
     c_id = self.request.get('con_id')
     con = Contention.get_by_id(int(c_id))
     elem_id = self.request.get('elem_id')
     elem_type = self.request.get('etype')
     date = self.request.get('date')
     if elem_type == "con":
         con.other_date = date
         con.put()
     else:
         e = Elements.get_by_id(int(elem_id))
         e.other_date = date
         e.put()
Ejemplo n.º 2
0
 def post(self):
     etype = self.request.get('etype')
     elem_id = self.request.get('elem_id')
     con_id = self.request.get('con_id')
     lat = float(self.request.get('lat'))
     lng = float(self.request.get('lng'))
     placename = self.request.get('placename')
     if elem_id == "con":
         con = Contention.get_by_id(int(con_id))
         con.latlng = db.GeoPt(lat, lng)
         con.placename = placename
         con.put()
     else:
         elem = Elements.get_by_id(int(elem_id))
         elem.latlng = db.GeoPt(lat, lng)
         elem.placename = placename
         elem.put()
Ejemplo n.º 3
0
 def post(self):
     type = self.request.get("i_type")
     the_ID = self.request.get("i_entity_id")
     con_ID = self.request.get("con_id")
     reDirStr = '/cv?con_id=' + str(con_ID)
     image_Num = self.request.get("i_num")
     upload_files = self.get_uploads('file')
     if type == "con":
         c = Contention.get_by_id(int(the_ID))
         blob_info = upload_files[0]
         c.image1 = blob_info.key()
         c.put()
     else:
         e = Elements.get_by_id(int(the_ID))
         blob_info = upload_files[0]
         e.image1 = blob_info.key()
         e.put()
     self.redirect(reDirStr)
Ejemplo n.º 4
0
 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()
Ejemplo n.º 5
0
    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())
Ejemplo n.º 6
0
    def get(self):
        edit = self.request.get('edit')
        type = self.request.get('type')
        #contention_query =  Contention.all().order('-date')
        #cons = contention_query.fetch(10)
        #count = int(cons.count(10))+1
        branch_query = Branch.all().order('branch')
        branches = branch_query.fetch(10)
        ari_query = Ari_types.all().order('ari')
        aris = ari_query.fetch(50)
        if edit == "0" or edit == "":
            p_type = "contention"
            params = {
                'branches': branches,
                'con': "",
                'reasons': "",
                'objections': "",
                'edit': edit,
                'p_type': p_type,
                'aris': aris
            }
        elif edit == "1":
            contention_ID = self.request.get('c_id')
            con = Contention.get_by_id(int(contention_ID))
            p_type = "contention"
            reasons = {}
            objections = {}
            if con:
                elems = con.elements.fetch(50)
                count = int(elems.count(20)) + 1
                rsn = 0
                objn = 0
                for f in elems:
                    if f.top_level == 1:
                        if f.element_type == 'reason':
                            rsn = rsn + 1
                            reasons['reason' + str(rsn)] = f
                        if f.element_type == 'objection':
                            objn = objn + 1
                            objections['objection' + str(objn)] = f
            params = {
                'branches': branches,
                'edit': edit,
                'p_type': p_type,
                'con': con,
                'elems': elems,
                'reasons': reasons,
                'objections': objections,
                'aris': aris,
                #'count': count,
            }
        elif edit == "2":
            contention_ID = self.request.get('c_id')
            con = Contention.get_by_id(int(contention_ID))
            p_type = "element"
            reasons = []
            objections = []
            if con:
                elems = con.elements.fetch(50)
                count = int(elems.count(20)) + 1
                elem_ID = int(self.request.get('e_id'))
                rsn = 0
                objn = 0
                for f in elems:
                    if f.parent_id == elem_ID:
                        if f.element_type == 'reason':
                            rsn = rsn + 1
                            reasons['reason' + str(rsn)] = f
                        if f.element_type == 'objection':
                            objn = objn + 1
                            objections['objection' + str(objn)] = f
            #edit_gols['subnodes']=slvl
            elem_ID = self.request.get('e_id')
            elem = Elements.get_by_id(int(elem_ID))
            params = {
                'branches': branches,
                'edit': edit,
                'p_type': p_type,
                'con': con,
                'elem': elem,
                'reasons': reasons,
                'objections': objections,
                'aris': aris,
                'form_url': blobstore.create_upload_url('/upload')
                #'count': count,
            }

        # if users.get_current_user():
        # url = users.create_logout_url(self.request.uri)
        # url_linktext = 'Logout'
        # else:
        # url = users.create_login_url(self.request.uri)
        # url_linktext = 'Login'

        return self.render('argu_form.html', params)
Ejemplo n.º 7
0
 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')
     pid = self.request.get('pid')
     content = self.request.get('content')
     ss = int(self.request.get('ss'))       
     elems = _con.elements
     e=Elements()           
     contot = _con.tot_element_code
     updated_codes = element_code_update(pid,contot)
     e.element_id = updated_codes['element_id']
     e.parent_id = pid
     e.content = content
     e.sure_score = ss
     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']
     step=int(self.request.get('step'))+1
     _con.g_frame=step
     _con.tot_element_code = updated_codes['tot_element_code']
     elems.append(e)
     _con.elements = elems
     _con.put()
     user_ID = sessiony['user_id']
     u = User.get_by_id(int(user_ID))
     cid = _con.key.id()
     ckey = _con.key  
     g = GPoints()
     uid = u.key.id()
     ukey = ndb.Key(User, uid)
     logging.info("key id = " + str(uid ))
     logging.info("ndb key = ")
     logging.info(ukey)
     g.user_key = ukey
     g.user_name = self.current_user.name
     g.points_log = "Posted " + elem_type
     g.contention_key = ckey
     g.contention_id = cid
     g.element_id = updated_codes['element_id']
     g.branch_name = branch_name
     g.points = 10
     g.elem_type = elem_type
     g.content = content
     g.put()
     logging.info('+++++++++++++++++report 1 for con id ='+ c_ID + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
     logging.info(_con.elements)
     logging.info('++++++++++++++++++end report 1+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
     newcon = Contention.get_by_id(int(c_ID))
     logging.info('+++++++++++++++++report 2 for con id ='+ c_ID + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
     for i in newcon.elements:
         logging.info(i.element_id)
         logging.info(i.content)
         logging.info(newcon.elements)
     logging.info('++++++++++++++++++end report 2+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
     self.redirect('/cv?con_id=%s' % _con.key.id())