Exemple #1
0
 def post(self, firmid):
     """create a new firm"""
     firm = model.Firm.get_by_id(firmid)
     if firm:
         #firm already exists. returns conflict
         self.error(409)
     else:
         d = json.loads( self.request.body )
         firm = model.Firm( key = model.firm_key(firmid), **d )
         firm.put()
Exemple #2
0
 def post(self, firmid):
     """create a new firm"""
     firm = model.Firm.get_by_id(firmid)
     if firm:
         #firm already exists. returns conflict
         self.error(409)
     else:
         d = json.loads(self.request.body)
         firm = model.Firm(key=model.firm_key(firmid), **d)
         firm.put()
Exemple #3
0
 def get(self, firmid):
     """returns a firm with firmid"""
     key = model.firm_key( firmid )
     firm = key.get()
     if not firm:
         self.error(404)
     else:
         js = json.dumps( firm.to_dict() )        
         self.json_content()
         self.w( js )
Exemple #4
0
 def get(self, firmid):
     """returns a firm with firmid"""
     key = model.firm_key(firmid)
     firm = key.get()
     if not firm:
         self.error(404)
     else:
         js = json.dumps(firm.to_dict())
         self.json_content()
         self.w(js)
Exemple #5
0
 def post(self):
     firmid = self.request.get('firmid')
     firm = model.firm_key( firmid ).get()
     if firm:
         #update the firm
         firm.name_e = self.request.get('name_e')
         firm.name_h = self.request.get('name_h')
         firm.about_e = self.request.get('about_e')
         firm.about_h = self.request.get('about_h')
         firm.put()
         self.redirect('/%s/admin/firm_status' % firmid)
     else:
         self.redirect('/%s/admin/firm' % firmid)
Exemple #6
0
 def post(self):
     firmid = self.request.get('firmid')
     firm = model.firm_key(firmid).get()
     if firm:
         #update the firm
         firm.name_e = self.request.get('name_e')
         firm.name_h = self.request.get('name_h')
         firm.about_e = self.request.get('about_e')
         firm.about_h = self.request.get('about_h')
         firm.put()
         self.redirect('/%s/admin/firm_status' % firmid)
     else:
         self.redirect('/%s/admin/firm' % firmid)
Exemple #7
0
    def get(self, firmid, projid, imgid):
        key = model.firm_key(firmid)
        firm = key.get()

        img_key = ndb.Key("Firm", firmid, "Project", projid, "Image", imgid)
        image = img_key.get()
        img = image.to_dict()
        tmpl_name = 'admin/image_data.html'

        self.html_content()
        self.w(globals.jinja_env.get_template(tmpl_name).render({
            'firm': firm.to_dict(),
            'firmid': firmid,
            'projid': projid,
            'imgid': imgid,
            'img': img,
        }))
Exemple #8
0
    def get(self, firmid, projid):
        firm_key = model.firm_key(firmid)
        firm = firm_key.get()
        proj_key = ndb.Key('Firm', firmid, 'Project', projid)
        proj = proj_key.get()

        self.html_content()
        upload_url = create_upload_url(firmid, projid)
        tmpl_name = 'admin/image.html'
        html = globals.jinja_env.get_template(tmpl_name).render({
            'firm': firm.to_dict(),
            'proj': proj,
            'firmid': firmid,
            'projid': projid,
            'upload_url': upload_url,
        })
        self.w(html)
Exemple #9
0
 def get(self, firmid):
     key = model.firm_key( firmid )
     firm = key.get()
     if not firm:
         firm = model.Firm(key=key)
         firm.put()
     projects = model.Project.query_firm(key).fetch()
     
     tmpl = globals.jinja_env.get_template( 'admin/firm.html' )
     html = tmpl.render({
         'firmid': firmid,
         'firm': firm.to_dict(),
         'projects': projects                 
     })
     
     self.html_content()
     self.w( html )
     pass
Exemple #10
0
    def get(self, firmid):
        key = model.firm_key(firmid)
        firm = key.get()
        if not firm:
            firm = model.Firm(key=key)
            firm.put()
        projects = model.Project.query_firm(key).fetch()

        tmpl = globals.jinja_env.get_template('admin/firm.html')
        html = tmpl.render({
            'firmid': firmid,
            'firm': firm.to_dict(),
            'projects': projects
        })

        self.html_content()
        self.w(html)
        pass
Exemple #11
0
    def get(self, firmid, projid):
        firm_key = model.firm_key(firmid)
        firm = firm_key.get()
        proj_key = ndb.Key('Firm', firmid, 'Project', projid)
        proj = proj_key.get()

        self.html_content()
        upload_url = create_upload_url(firmid, projid)
        tmpl_name = 'admin/image.html'
        html = globals.jinja_env.get_template(tmpl_name).render({
            'firm':
            firm.to_dict(),
            'proj':
            proj,
            'firmid':
            firmid,
            'projid':
            projid,
            'upload_url':
            upload_url,
        })
        self.w(html)
Exemple #12
0
    def get(self, firmid, projid, imgid):
        key = model.firm_key(firmid)
        firm = key.get()

        img_key = ndb.Key("Firm", firmid, "Project", projid, "Image", imgid)
        image = img_key.get()
        img = image.to_dict()
        tmpl_name = 'admin/image_data.html'

        self.html_content()
        self.w(
            globals.jinja_env.get_template(tmpl_name).render({
                'firm':
                firm.to_dict(),
                'firmid':
                firmid,
                'projid':
                projid,
                'imgid':
                imgid,
                'img':
                img,
            }))
Exemple #13
0
    def get(self, firmid, projid):
        """

        :param firmid:
        :param projid:
        """
        new_proj = None
        p = None
        images = None
        firm_key = model.firm_key(firmid)
        firm = firm_key.get()

        if projid:
            new_proj = False
            key = ndb.Key("Firm", firmid, "Project", projid)
            p = key.get().to_dict()
            _images = model.Image.query(ancestor=key).fetch()
            images = [img.to_dict() for img in _images]

        else:
            new_proj = True
            p = {}
            images = []

        tmpl = main.jinja_env.get_template('admin/project.html')
        html = tmpl.render({
            'firmid': firmid,
            'projid': projid,
            'firm': firm.to_dict(),
            'new_proj': new_proj,
            'p': p,
            'images': images,
        })
        self.html_content()
        self.w(html)
        pass