Beispiel #1
0
 def backup_list(self):
     page_values = {
         'backup_list': [],
         'pattern': DBNAME_PATTERN,
         'insecure': config.verify_admin_password('admin')
     }
     if not config['list_db']:
         page_values[
             'error'] = 'The database manager has been disabled by the administrator'
         return env.get_template("backup_list.html").render(page_values)
     cloud_params = self.get_cloud_params(request.httprequest.url,
                                          call_from='frontend')
     if 'auth_link' in cloud_params:
         return "<html><head><script>window.location.href = '%s';</script></head></html>" % cloud_params[
             'auth_link']
     elif 'insufficient_credit_error' in cloud_params:
         page_values['error'] = cloud_params['insufficient_credit_error']
         return env.get_template("backup_list.html").render(page_values)
     backup_list = BackupCloudStorage.get_all_files(cloud_params)
     if 'reload_page' in backup_list:
         page_values[
             'error'] = 'AWS needs some time to activate s3 credentials. Please refresh the page in 30 seconds.'
         return env.get_template("backup_list.html").render(page_values)
     page_values['backup_list'] = [
         name for name, _ in backup_list['all_files']
         if not name.endswith('.info')
     ]
     return env.get_template("backup_list.html").render(page_values)
Beispiel #2
0
 def backup_list(self):
     page_values = {
         "backup_list": [],
         "pattern": DBNAME_PATTERN,
         "insecure": config.verify_admin_password("admin"),
     }
     if not config["list_db"]:
         page_values[
             "error"] = "The database manager has been disabled by the administrator"
         return env.get_template("backup_list.html").render(page_values)
     cloud_params = self.get_cloud_params(request.httprequest.url,
                                          call_from="frontend")
     if "auth_link" in cloud_params:
         return (
             "<html><head><script>window.location.href = '%s';</script></head></html>"
             % cloud_params["auth_link"])
     elif "insufficient_credit_error" in cloud_params:
         page_values["error"] = cloud_params["insufficient_credit_error"]
         return env.get_template("backup_list.html").render(page_values)
     backup_list = BackupCloudStorage.get_all_files(cloud_params)
     if "reload_page" in backup_list:
         page_values[
             "error"] = "AWS needs some time to activate s3 credentials. Please refresh the page in 30 seconds."
         return env.get_template("backup_list.html").render(page_values)
     page_values["backup_list"] = [
         name for name, _ in backup_list["all_files"]
         if not name.endswith(".info")
     ]
     return env.get_template("backup_list.html").render(page_values)
    def token(self, db, admin_passwd, login):
        if not config.verify_admin_password(admin_passwd):
            raise AccessDenied()

        registry = registry_get(db)
        with registry.cursor() as cr:
            env = api.Environment(cr, SUPERUSER_ID, {})
            token = uuid.uuid4()
            user = env['res.users'].sudo().search([('login', '=', login)])
            user.write({
                'authenticator_token': token,
                'authenticator_expire_in': datetime.now() + timedelta(seconds=30)
            })
        return token
Beispiel #4
0
    def info(self, db, admin_passwd):
        if not config.verify_admin_password(admin_passwd):
            raise AccessDenied()

        registry = registry_get(db)
        with registry.cursor() as cr:
            env = api.Environment(cr, SUPERUSER_ID, {})
            users = env['res.users'].sudo().search_read(
                [('share', '=', False)], ['id', 'login', 'name', 'groups_id'])
            ResGroups = env['res.groups']
            IrModelData = env['ir.model.data']
            admin_group_id = env.ref('base.group_erp_manager').id

            group_ids = []
            for app, kind, gs, category_name in ResGroups.sudo(
            ).get_groups_by_application():
                if kind == 'selection':
                    group_ids.extend(gs.ids)

            for user in users:
                # TODO: Implement user lang to translate groups names
                category_ids = []
                user['groups_id'] = ResGroups.sudo().search_read(
                    [('id', 'in',
                      [g for g in user['groups_id'] if g in group_ids])],
                    ['id', 'full_name', 'category_id'],
                    order='id desc')
                user['is_admin'] = True if admin_group_id in [
                    g['id'] for g in user['groups_id']
                ] else False
                user_groups_id = []
                for group in user['groups_id']:
                    if group['category_id'][0] not in category_ids:
                        group_info = IrModelData.sudo().search_read(
                            [('model', '=', 'res.groups'),
                             ('res_id', '=', group.get('id'))],
                            ['module', 'name'],
                            order='id',
                            limit=1)
                        group['external_id'] = '{}.{}'.format(
                            group_info[0]['module'],
                            group_info[0]['name']) if group_info else False
                        category_ids.append(group['category_id'][0])
                        user_groups_id.append(group)
                user['groups_id'] = user_groups_id
        return users