コード例 #1
0
ファイル: teamboxes.py プロジェクト: fdgonthier/kas
    def show_kws_mgt_specific_page(self, kws_info):
        
        action_url = url_for('teamboxes')
        c.kws_id = kws_info.kws_id
        c.action_url = action_url
        c.back_url = action_url + "?kws_mgt_reshow_kws=1"
        c.kws_ro_link = action_url + "?kws_id=%i&kwmo_redir=1" % ( kws_info.kws_id )
        c.kws_name = kws_info.name
        
        c.kws_creator = ""
        if len(kws_info.user_list): c.kws_creator += kws_info.user_list[0].email + " "
        if kws_info.org_name: c.kws_creator += "(" + kws_info.org_name + ")"

        c.kws_date = self.format_kws_date(kws_info.creation_date)
        
        tmp = ""
        for user in kws_info.user_list:
            if user.name: middle = user.name + " (" + user.email + ")"
            else: middle = user.email
            tmp += "    <tr><td>%s</td></tr>\n" % (kweb_lib.html_text_escape(middle))
        c.member_list = tmp
        
        c.kws_file_size = self.format_as_mb(kws_info.file_size, 2)
        c.kws_quota = self.format_as_mb(kws_info.file_quota, 0)
        
        return render('/teamboxes/specific.mako')
コード例 #2
0
ファイル: status.py プロジェクト: fdgonthier/kas
    def show(self):

        if c.mc.production_mode:
            # Get kplatshell status line.
            status_line = get_status_line()
            if status_line == 'OK': ui_info(message='The services are running normally.')
            else: ui_warn(message=status_line)

        # Show production line.
        if c.mc.production_mode: ui_info(message='This server is in production mode.')
        else: ui_warn(message='This server is in maintenance mode.')

        c.production_mode = bool(c.mc.production_mode)

        # Return template.
        return render('/status/show.mako')
コード例 #3
0
    def show(self):

        if c.mc.production_mode:
            # Get kplatshell status line.
            status_line = get_status_line()
            if status_line == 'OK':
                ui_info(message='The services are running normally.')
            else:
                ui_warn(message=status_line)

        # Show production line.
        if c.mc.production_mode:
            ui_info(message='This server is in production mode.')
        else:
            ui_warn(message='This server is in maintenance mode.')

        c.production_mode = bool(c.mc.production_mode)

        # Return template.
        return render('/status/show.mako')
コード例 #4
0
ファイル: login.py プロジェクト: fdgonthier/kas
    def login(self):
        # The user is already logged in; redirect to the status page.
        if web_session.has_key('logged') and web_session['logged']:
            return redirect(url_for('status'))

        # Initialize web session.
        self._init_session()

        # Load master config.
        master_config = load_master_config()

        # FIXME: isinstance(...) could be removed if property has a null=False parameter... check that with Laurent.
        pwd = None
        if isinstance(master_config.admin_pwd,
                      basestring) and len(master_config.admin_pwd) > 0:
            # Admin password is set.

            # Get the provided password, if any.
            pwd = request.POST.get('cfg_password', None)

            if pwd:
                if pwd == master_config.admin_pwd:
                    # User has provided the right password.
                    self._login()

                    # Redirect to the status page.
                    return redirect(url_for('status'))

                else:
                    # Show a bad password message.
                    ui_error(message=GT("login.bad_password"))

        else:
            # Admin password is not set yet; show a warning message.
            ui_error(message=GT("locals.admin_password_not_set"))

        # Push variables to template.
        c.pwd = pwd
        c.GT = GT

        return render('/login/login.mako')
コード例 #5
0
ファイル: teamboxes.py プロジェクト: fdgonthier/kas
    def show(self):
        # Push variables to templates.
        c.GT = GT
        c.dyn_ress_id = dyn_ress_id
 
        try:
            # Make sure KCD database is reachable.
            db_session.execute('SELECT 1')
        except OperationalError:
            ui_error(message="Database connection to MAS could not be established. You might want to check the configuration.")
            return render('/common/message.mako')

        # Dispatch.
        if get_var("kws_mgt_specific_kws"): return self.kws_mgt_specific()
        elif get_var("kws_mgt_query_action"): return self.kws_mgt_query_action()
        elif get_var("kws_mgt_show_kws"): return self.kws_mgt_show()
        elif get_var("kws_mgt_reshow_kws"): return self.show_kws_mgt_query_page()
        elif get_var("kws_mgt_next_kws"): return self.kws_mgt_next()
        elif get_var("kws_mgt_last_kws"): return self.kws_mgt_last()
        elif get_var("kwmo_redir"): return self.kws_mgt_kwmo_management()
        else: return self.kws_mgt_new_query()
コード例 #6
0
ファイル: login.py プロジェクト: fdgonthier/kas
    def login(self):
        # The user is already logged in; redirect to the status page.
        if web_session.has_key('logged') and web_session['logged']:
            return redirect(url_for('status'))

        # Initialize web session.
        self._init_session()

        # Load master config.
        master_config = load_master_config()
       
        # FIXME: isinstance(...) could be removed if property has a null=False parameter... check that with Laurent.
        pwd = None
        if isinstance(master_config.admin_pwd, basestring) and len(master_config.admin_pwd) > 0:
            # Admin password is set.

            # Get the provided password, if any.
            pwd = request.POST.get('cfg_password', None)

            if pwd:
                if pwd == master_config.admin_pwd:
                    # User has provided the right password.
                    self._login()

                    # Redirect to the status page.
                    return redirect(url_for('status'))

                else:
                    # Show a bad password message.
                    ui_error(message=GT("login.bad_password"))

        else:
            # Admin password is not set yet; show a warning message.
            ui_error(message=GT("locals.admin_password_not_set"))

        # Push variables to template.
        c.pwd = pwd 
        c.GT = GT

        return render('/login/login.mako')
コード例 #7
0
ファイル: teamboxes.py プロジェクト: fdgonthier/kas
 def show_kws_mgt_query_page(self):
    
     # Define the session variables, if required.
     if not web_session.has_key("kws_mgt_query_offset"):
         self.reset_kws_mgt_query()
     
     # Obtain the Teambox list.
     kws_list = self.get_kws_mgt_kws_list(web_session["kws_mgt_query_offset"], web_session["kws_mgt_query_limit"])
     
     # Obtain the information about the Teamboxes.
     kws_dict = odict()
     for kws_id in kws_list: kws_dict[kws_id] = self.get_kws_mgt_kws_info(kws_id)
     
     # Show the information.
     action_url = url_for('teamboxes')
     
     # Get the Teambox list content.
     s = ""
     for kws_info in kws_dict.values():
         kws_href = action_url + "?kws_mgt_specific_kws=%i" % (kws_info.kws_id)
         s += '    <tr>\n'
         s += '      <td><input type="checkbox" name="kws_mgt_kws_cb_%i"/></td>\n' % (kws_info.kws_id)
         s += '      <td class="kwstableid">%i</td>\n' % (kws_info.kws_id)
         s += '      <td class="kwstablename"><a href="%s">%s</a></td>\n' % \
              (kws_href, kweb_lib.html_text_escape(kws_info.name))
         s += '      <td class="kwstablestats">%i</td>\n' % (len(kws_info.user_list))
         s += '      <td class="kwstablestats">%s MiB</td>\n' % (self.format_as_mb(kws_info.file_size, 2))
         s += '      <td class="kwstablestats">%s</td>\n' % (self.format_kws_date(kws_info.creation_date))
         s += '      <td class="kwstablestats">%s</td>\n' % (kweb_lib.html_text_escape(kws_info.org_name))
         s += '    </tr>\n'
     kws_table_body = s
    
     # Push variables to template.  
     c.action_url = action_url
     c.kws_table_body = kws_table_body
     c.kws_mgt_query_offset = web_session["kws_mgt_query_offset"] + 1
     c.kws_mgt_query_limit = web_session["kws_mgt_query_limit"]
     
     return render('/teamboxes/query.mako')
コード例 #8
0
ファイル: abstract_config.py プロジェクト: fdgonthier/kas
    def show(self):

        ## Check that server is in maintenance mode.
        #if c.mc.production_mode:
        #    # Redirect to the status page.
        #    return redirect_to(url_for('status'))

        # Push variables to template.
        c.GT = GT
        c.dyn_ress_id = dyn_ress_id
        c.template_store = {}
 
        # Determine which form has been requested or posted, if any.
        requested_form = get_var('form') or ""
        
        # Setup the configuration page forms.
        forms = Forms()
        self.get_config_page_forms(forms, requested_form)
        
        # Process the configuration page posted form, if any.
        self.process_config_page_posted_form(forms, requested_form)
       
        # Render the result.
        return render(self.config_template)
コード例 #9
0
    def show(self):

        ## Check that server is in maintenance mode.
        #if c.mc.production_mode:
        #    # Redirect to the status page.
        #    return redirect_to(url_for('status'))

        # Push variables to template.
        c.GT = GT
        c.dyn_ress_id = dyn_ress_id
        c.template_store = {}

        # Determine which form has been requested or posted, if any.
        requested_form = get_var('form') or ""

        # Setup the configuration page forms.
        forms = Forms()
        self.get_config_page_forms(forms, requested_form)

        # Process the configuration page posted form, if any.
        self.process_config_page_posted_form(forms, requested_form)

        # Render the result.
        return render(self.config_template)
コード例 #10
0
ファイル: license.py プロジェクト: fdgonthier/kas
 def show(self):
     return render('license/license.mako')
コード例 #11
0
ファイル: user_management.py プロジェクト: fdgonthier/kas
    def show(self):
        if not (c.services['freemium'].configured and c.services['freemium'].enabled):
            # Disallow access.
            return redirect(url_for('status'))

        # Return a rendered template
        page = 0
        limit = 25
        email_criteria = ''
        license_criteria = ''

        order_by = 'email'
        order_dir = 'asc'
        
        if 'order_by' in request.params:
            order_by = request.params['order_by']
        
        if 'order_dir' in request.params:
            order_dir = request.params['order_dir']

        if order_by == 'license':
            order_clause = User.license
        elif order_by == 'email':
            order_clause = User.email
        elif order_by == 'created':
            order_clause = User.created_on

        if order_dir == 'asc':
            order_clause = asc(order_clause)
        else:
            order_clause = desc(order_clause)
            
            
        if 'page' in request.params:
            try:
                tmp_page = int(request.params['page'])
                if tmp_page > 0:
                    page = tmp_page - 1
            except:
                pass

        if 'limit' in request.params:
            try:
                tmp_limit = int(request.params['limit'])
                if tmp_limit > 0:
                    limit = tmp_limit
            except:
                pass
        
        if 'email_criteria' in request.params and request.params['email_criteria'].strip():
            email_criteria = request.params['email_criteria'].strip()

        if 'license_criteria' in request.params:
            license_criteria = request.params['license_criteria']
        
        offset = page * limit
        query = User.query
        
        if email_criteria:
            query = query.filter(User.email.like('%' + email_criteria + '%'))
        
        if (not license_criteria) or license_criteria == 'all':
            pass
        elif license_criteria == 'except_none':
            query = query.filter(User.license !='none')
        else:
            query = query.filter(User.license == license_criteria)
       
        query = query.filter(User.org_id == self.getFreemiumOrgId())
                
        c.users = query.order_by(order_clause).limit(limit).offset(offset)
        c.users_count = query.count()
        c.page_count = int(math.ceil(c.users_count/float(limit)))
        c.select_license_criteria = {'all':'', 'except_none':'', 'none':'', 'confirm':'', 'gold':'', 'freemium':'', 'bronze':'', 'silver':''}
        c.license_criteria = license_criteria
        c.select_license_criteria[license_criteria] = 'selected'
        c.email_criteria = email_criteria
        c.page = page + 1
        c.order_by = order_by
        c.order_dir = order_dir
           
        c.limit = limit

        return render('/user_management/show.mako')
コード例 #12
0
ファイル: user_management.py プロジェクト: fdgonthier/kas
    def show(self):
        if not (c.services['freemium'].configured
                and c.services['freemium'].enabled):
            # Disallow access.
            return redirect(url_for('status'))

        # Return a rendered template
        page = 0
        limit = 25
        email_criteria = ''
        license_criteria = ''

        order_by = 'email'
        order_dir = 'asc'

        if 'order_by' in request.params:
            order_by = request.params['order_by']

        if 'order_dir' in request.params:
            order_dir = request.params['order_dir']

        if order_by == 'license':
            order_clause = User.license
        elif order_by == 'email':
            order_clause = User.email
        elif order_by == 'created':
            order_clause = User.created_on

        if order_dir == 'asc':
            order_clause = asc(order_clause)
        else:
            order_clause = desc(order_clause)

        if 'page' in request.params:
            try:
                tmp_page = int(request.params['page'])
                if tmp_page > 0:
                    page = tmp_page - 1
            except:
                pass

        if 'limit' in request.params:
            try:
                tmp_limit = int(request.params['limit'])
                if tmp_limit > 0:
                    limit = tmp_limit
            except:
                pass

        if 'email_criteria' in request.params and request.params[
                'email_criteria'].strip():
            email_criteria = request.params['email_criteria'].strip()

        if 'license_criteria' in request.params:
            license_criteria = request.params['license_criteria']

        offset = page * limit
        query = User.query

        if email_criteria:
            query = query.filter(User.email.like('%' + email_criteria + '%'))

        if (not license_criteria) or license_criteria == 'all':
            pass
        elif license_criteria == 'except_none':
            query = query.filter(User.license != 'none')
        else:
            query = query.filter(User.license == license_criteria)

        query = query.filter(User.org_id == self.getFreemiumOrgId())

        c.users = query.order_by(order_clause).limit(limit).offset(offset)
        c.users_count = query.count()
        c.page_count = int(math.ceil(c.users_count / float(limit)))
        c.select_license_criteria = {
            'all': '',
            'except_none': '',
            'none': '',
            'confirm': '',
            'gold': '',
            'freemium': '',
            'bronze': '',
            'silver': ''
        }
        c.license_criteria = license_criteria
        c.select_license_criteria[license_criteria] = 'selected'
        c.email_criteria = email_criteria
        c.page = page + 1
        c.order_by = order_by
        c.order_dir = order_dir

        c.limit = limit

        return render('/user_management/show.mako')
コード例 #13
0
 def show(self):
     return render('license/license.mako')