Ejemplo n.º 1
0
 def post(self):
     alias = self.get_argument('alias')
     url = self.get_argument('url')
     user = self.get_current_user()
     with self.__dbm.db() as db:
         db.store(alias, Alias.to_json(Alias(url, user)))
     self.redirect('/admin')
Ejemplo n.º 2
0
 def post(self):
     alias = self.get_argument('alias')
     url = self.get_argument('url')
     user = self.get_current_user()
     with self.__dbm.db() as db:
         db.store(alias, Alias.to_json(Alias(url, user)))
     self.redirect('/admin')
Ejemplo n.º 3
0
    def get(self):
        user = self.get_current_user()

        # get data from the database
        records = {}
        with self.__dbm.db() as db:
            record_count = db.count()
            # transform db records from string to Alias
            for k, v in db.records().items():
                records[k] = Alias.from_json(v)

        self.render('admin.html', user=user, page='admin', \
                    records=records, record_count=record_count)
Ejemplo n.º 4
0
    def get(self):
        user = self.get_current_user()

        # get data from the database
        records = {}
        with self.__dbm.db() as db:
            record_count = db.count()
            # transform db records from string to Alias
            for k, v in db.records().items():
                records[k] = Alias.from_json(v)

        self.render('admin.html', user=user, page='admin', \
                    records=records, record_count=record_count)
Ejemplo n.º 5
0
    def import_file(self, json_path):
        data = json.load(open(json_path, 'r'))

        try:
            self._validate_json(data)
        except:
            return

        for staff_json in data['staffs']:
            staff_entity = self.get_or_create_staff(staff_json)
            # Add record in movie_staffs
            self.session.add(MovieStaff(movie_id=data['id'],
                                        staff_id=staff_json['id'],
                                        type=MovieStaff.get_type_by_roles(staff_json['roles'])))

        mov = Movie(id=data['id'],
                    title=data['title'],
                    original_title=data['original_title'],
                    rating=float(data['rating']['value']),
                    introduction=data['intro'],
                    poster=data['pic']['large'],
                    year=(int(data['year']) if data['year'].isdigit() else None),
                    languages=','.join(data['languages']),
                    countries=','.join(data['countries']),
                    publish_dates=','.join(data['pubdate']),
                    review_count=int(data['review_count']),
                    durations=','.join(data['durations']),
                    is_tv=data['is_tv'],
                    # association with other entities
                    genres=[self.get_or_create_genre(genre)
                            for genre in data['genres']],
                    tags=[self.get_or_create_tag(tag['name'])
                          for tag in data['tags']],
                    aliases=[Alias(movie_id=data['id'], alias=alias)
                             for alias in data['aka']])

        self.session.add(mov)
Ejemplo n.º 6
0
 def get(self, alias):
     with self.__dbm.db() as db:
         desc = Alias.from_json(db.load(alias))
         self.redirect(desc.get_url())
Ejemplo n.º 7
0
 def get(self, alias):
     with self.__dbm.db() as db:
         desc = Alias.from_json(db.load(alias))
         self.redirect(desc.get_url())