Exemple #1
0
    def get(self):
        user = self.get_current_user()
        if user:
            logger.error(str(user))
            if user['uid'] > MAX_ADMIN_UID:
                raise tornado.web.HTTPError(404, 'Page Not Found!')
        users_total = yield self.get_users_total()

        users = User.select()

        try:
            config = Config.select().where(Config.id == 1).get()
        except Config.DoesNotExist:
            config = Config()

        msg = self.get_argument('msg', '')
        page = int(self.get_argument('page', '1'))
        page_size = 100
        offset = page_size * (page - 1)

        kwargs = {
            'msg': msg,
            'users': users,
            'users_total': users_total,
            'config': config,
        }
        self.render("admin/system.html", **kwargs)
Exemple #2
0
    def config(self, api_port):
        logger.info('Configuring alcazard with state at {}', self.state_path)

        api_port = api_port or DEFAULT_PORT

        os.makedirs(self.state_path, exist_ok=True)
        DB.init(self.db_path)

        with DB:
            self._init_db()

            config = Config.select().first()
            if not config:
                from transmission.params import DEFAULT_TRANSMISSION_SETTINGS_TEMPLATE
                config = Config(
                    is_fully_configured=True,
                    transmission_settings=
                    DEFAULT_TRANSMISSION_SETTINGS_TEMPLATE,
                    is_dht_enabled=False,
                    local_port_pools_fmt='9091-9291',
                    peer_port_pools_fmt='21413-21613',
                )

            config.api_port = api_port
            config.save()

        logger.info('Saved configuration - done.')
Exemple #3
0
    def build_config_records_filter():
        mapping = {'working_tree': 'nest'}
        query_str = ''
        for filter_ in Config.select().where(
                        Config.status == 1 & Config.type << ['working_tree']):

            mapping_result = mapping.get(filter_.type)
            if mapping_result:
                query_str += mapping_result + '::' + filter_.data
        return query_str
Exemple #4
0
 def reload_config(self):
     try:
         config=Config.select().where(Config.id==1).get()
     except:
         config=Config(sitename='ABCcms', siteurl='http://localhost')
     config_keys=config._meta.fields.keys()
     print config_keys
     config_keys.remove('id')
     config_keys.remove('created_at')
     config_keys.remove('updated_at')
     for key in config_keys:
         if not hasattr(self,key):
             setattr(self,key,getattr(config, key))
         else:
             setattr(self,key,getattr(config, key))
Exemple #5
0
from models import db, Config

try:
    config=Config.select().where(Config.id==1).get()
except:
    config=Config(sitename='ABCcms', siteurl='http://localhost')
config.shutdown=False
config.save()
Exemple #6
0
    def post(self):
        #print self.request
        #print self.request.body
        #print self.request.arguments
        #print self.request.files.keys()
        #print self.request.files['logo']
        #print '-'*80

        config_id = int(self.get_argument('config_id', '1'))
        ip = self.get_argument('ip', '')
        domain = self.get_argument('domain', '')
        sitename = self.get_argument('sitename', '')
        siteurl = self.get_argument('siteurl', '')
        title = self.get_argument('title', '')
        keywords = self.get_argument('keywords', '')
        description = self.get_argument('description', '')
        copyright = self.get_argument('copyright', '')
        shutdown = int(self.get_argument('shutdown', '0'))
        reason = self.get_argument('reason', '')
        logo = self.get_argument('logo', '')
        print logo

        try:

            file_dict_list = self.request.files['logo']
        except KeyError:
            filename = None  # no image uploaded
        else:
            for fd in file_dict_list:
                filename = fd["filename"]
                ext = filename.split('.')[-1]
                filename = 'logo%s.%s' % (str(int(1000 * (time.time()))), ext)
                filepath = os.path.join(MEDIA_ROOT, 'images', filename)
                f = open(filepath, "wb")
                f.write(fd["body"])
                f.close()

        try:
            config = Config.select().where(Config.id == config_id).get()
        except:
            config_count = Config.select().count()
            if config_count > 0:
                raise tornado.web.HTTPError(500, 'Server Config is broken!')
            else:
                defaults = {}
                config = Config(sitename='ABCcms', siteurl='http://localhost')
                config.save()
        print config
        print 'shutdown', bool(shutdown)
        config.sitename = sitename
        config.siteurl = siteurl
        config.title = title
        config.keywords = keywords
        config.description = description
        config.copyright = copyright
        config.shutdown = bool(shutdown)
        config.reason = reason
        config.ip = ip
        config.domain = domain
        if filename:
            config.logo = filename
        config.save()

        self.redirect('/admin/channel')