コード例 #1
0
 def get(self, range_id, model_id):
     template = JINJA_ENVIRONMENT.get_template(
         'templates/carmodels/model_detail.html')
     model_range = ModelRange.get(range_id)
     car_model = CarModel.get(model_id)
     data = {'range': model_range, 'model': car_model}
     self.response.write(template.render(data))
コード例 #2
0
 def get(self, range_id, model_id):
     template = JINJA_ENVIRONMENT.get_template('templates/carmodels/model_detail.html')
     model_range = ModelRange.get(range_id)
     car_model = CarModel.get(model_id)
     data = {
         'range': model_range,
         'model': car_model
     }
     self.response.write(template.render(data))
コード例 #3
0
    def post(self, range_id):
        if self.request.get('cancel') == '1':
            return self.redirect('/ranges')

        model = ModelRange.get(range_id)
        model.name = self.request.get('name')
        model.year_start = int(self.request.get('yearfrom'))
        model.year_end = int(self.request.get('yearto'))
        model.notes = self.request.get('notes')
        model.put()
        return self.redirect('/ranges')
コード例 #4
0
    def post(self, range_id):
        if self.request.get('cancel') == '1':
            return self.redirect('/ranges')

        model = ModelRange.get(range_id)
        model.name = self.request.get('name')
        model.year_start = int(self.request.get('yearfrom'))
        model.year_end = int(self.request.get('yearto'))
        model.notes = self.request.get('notes')
        model.put()
        return self.redirect('/ranges')
コード例 #5
0
    def get(self, range_id):
        template = JINJA_ENVIRONMENT.get_template(
            'templates/carmodels/range_detail.html')
        model_range = ModelRange().get(range_id)

        data = {
            'range': model_range,
            'models': sorted(model_range.models, key=lambda x: -x.year_from),
            'counter': utils.counter.DataStoreCounter()
        }

        self.response.write(template.render(data))
コード例 #6
0
    def get(self):
        ranges = ModelRange.all().fetch(500)
        # Some trickery to sort the ranges properly
        ranges = sorted(ranges, key=lambda range: -self.year(range.year_end))
        ret = []
        for modelrange in ranges:
            # Skip the generic one
            if modelrange.name != 'Alfa Romeo' and modelrange.name != 'Ukjent':
                ret.append({
                    'key': str(modelrange.key()),
                    'name': modelrange.name,
                    'years': self.prettyprint_years(modelrange.year_start, modelrange.year_end)})

        self.response.content_type = 'application/json'
        self.response.write(json.dumps(ret))
コード例 #7
0
    def post(self, range_id, model_id):
        model_range = ModelRange.get(range_id)
        if self.request.get('cancel') == '1':
            return self.redirect('/ranges/' + str(model_range.key()) + '/edit')

        model = CarModel.get(model_id)
        model.name = self.request.get('name')
        model.year_from = int(self.request.get('yearfrom'))
        model.year_to = int(self.request.get('yearto'))
        model.typeno = self.request.get('tipo')
        model.engine_code = self.request.get('engine')
        url = self.request.get('image_url')
        if url != '':
            model.image_url = db.Link(url)
        model.notes = self.request.get('notes')
        model.put()
        return self.redirect('/ranges/' + str(model_range.key()) + '/edit')
コード例 #8
0
    def get(self, range_id):
        modelrange = ModelRange.get(range_id)
        ret = []
        if modelrange:
            models = modelrange.models.fetch(500)
            models = sorted(models, key=lambda model: -self.year(model.year_to))
            for model in models:
                ret.append({
                    'key': str(model.key()),
                    'name': model.name,
                    'tipo': model.typeno,
                    'motore': model.engine_code,
                    'years': self.prettyprint_years(model.year_from, model.year_to)
                    })

        self.response.content_type = 'application/json'
        self.response.write(json.dumps(ret))
コード例 #9
0
 def import_model_range(self, csv):
     lines = csv.split('\n')
     imported = 0
     for line in lines:
         if len(line.strip()) == 0:
             print 'Skipping line', line
             continue
         model_range = ModelRange()
         fields = line.strip().split(';')
         model_range.name = fields[0]
         model_range.year_start = int(fields[1])
         model_range.year_end = int(fields[2])
         model_range.put()
         imported = imported + 1
     print imported, 'ranges imported'
コード例 #10
0
    def post(self, range_id, model_id):
        model_range = ModelRange.get(range_id)
        if self.request.get('cancel') == '1':
            return self.redirect('/ranges/' + str(model_range.key()) + '/edit')


        model = CarModel.get(model_id)
        model.name = self.request.get('name')
        model.year_from = int(self.request.get('yearfrom'))
        model.year_to = int(self.request.get('yearto'))
        model.typeno = self.request.get('tipo')
        model.engine_code = self.request.get('engine')
        url = self.request.get('image_url')
        if url != '':
            model.image_url = db.Link(url)
        model.notes = self.request.get('notes')
        model.put()
        return self.redirect('/ranges/' + str(model_range.key()) + '/edit')
コード例 #11
0
def task_model_restore(items):
    model_count = 0
    for item in items:
        mrange = ModelRange()
        mrange.name = item['name']
        mrange.year_start = item['yearStart']
        mrange.year_end = item['yearEnd']
        mrange.notes = item['notes']
        mrange.put()
        for model in item['carModels']:
            carmodel = CarModel(key_name=model['modelId'])
            carmodel.name = model['name']
            carmodel.engine_code = model['engineCode']
            carmodel.typeno = model['typeNo']
            if model['imageUrl'] != None:
                carmodel.imageUrl = db.Link(model['imageUrl'])
            carmodel.year_from = model['yearFrom']
            carmodel.year_to = model['yearTo']
            carmodel.notes = model['notes']
            carmodel.model_range = mrange
            carmodel.put()
            model_count = model_count + 1
コード例 #12
0
ファイル: load.py プロジェクト: KlubbAlfaRomeoNorge/members
 def import_model_range(self, csv):
     lines = csv.split('\n')
     imported = 0
     for line in lines:
         if len(line.strip()) == 0:
             print 'Skipping line',line
             continue
         model_range = ModelRange()
         fields = line.strip().split(';')
         model_range.name = fields[0]
         model_range.year_start = int(fields[1])
         model_range.year_end = int(fields[2])
         model_range.put()
         imported = imported+1
     print imported,'ranges imported'
コード例 #13
0
 def import_car_models(self, csv):
     ranges = ModelRange.all().fetch(100)
     imported = 0
     lines = csv.split('\n')
     for line in lines:
         if len(line.strip()) == 0:
             print 'Skipping line', line
             continue
         model = CarModel()
         fields = line.strip().split(';')
         model.model_range = self.get_range(ranges, fields[0].strip())
         model.name = fields[1].strip()
         model.engine_code = fields[2].strip()
         model.typeno = fields[3].strip()
         if fields[4].strip() != '':
             model.image_url = db.Link(fields[4].strip())
         model.year_from = int(fields[5])
         model.year_to = int(fields[6])
         model.notes = fields[7].strip()
         model.put()
         imported = imported + 1
     print imported, 'models imported'
コード例 #14
0
ファイル: load.py プロジェクト: KlubbAlfaRomeoNorge/members
 def import_car_models(self, csv):
     ranges = ModelRange.all().fetch(100)
     imported = 0
     lines = csv.split('\n')
     for line in lines:
         if len(line.strip()) == 0:
             print 'Skipping line',line
             continue
         model = CarModel()
         fields = line.strip().split(';')
         model.model_range = self.get_range(ranges, fields[0].strip())
         model.name = fields[1].strip()
         model.engine_code = fields[2].strip()
         model.typeno = fields[3].strip()
         if fields[4].strip() != '':
             model.image_url = db.Link(fields[4].strip())
         model.year_from = int(fields[5])
         model.year_to = int(fields[6])
         model.notes = fields[7].strip()
         model.put()
         imported = imported + 1
     print imported,'models imported'
コード例 #15
0
def task_model_restore(items):
    model_count = 0
    for item in items:
        mrange = ModelRange()
        mrange.name = item['name']
        mrange.year_start = item['yearStart']
        mrange.year_end = item['yearEnd']
        mrange.notes = item['notes']
        mrange.put()
        for model in item['carModels']:
            carmodel = CarModel(key_name=model['modelId'])
            carmodel.name = model['name']
            carmodel.engine_code = model['engineCode']
            carmodel.typeno = model['typeNo']
            if model['imageUrl'] != None:
                carmodel.imageUrl = db.Link(model['imageUrl'])
            carmodel.year_from = model['yearFrom']
            carmodel.year_to = model['yearTo']
            carmodel.notes = model['notes']
            carmodel.model_range = mrange
            carmodel.put()
            model_count = model_count + 1
コード例 #16
0
 def get(self):
     template = JINJA_ENVIRONMENT.get_template('templates/carmodels/range_list.html')
     ranges = ModelRange.all().order('-year_start').fetch(500)
     data = { 'ranges' : ranges, 'counter': utils.counter.DataStoreCounter() }
     self.response.write(template.render(data))
コード例 #17
0
 def get(self):
     template = JINJA_ENVIRONMENT.get_template(
         'templates/carmodels/range_list.html')
     ranges = ModelRange.all().order('-year_start').fetch(500)
     data = {'ranges': ranges, 'counter': utils.counter.DataStoreCounter()}
     self.response.write(template.render(data))