コード例 #1
0
ファイル: auth.py プロジェクト: abhinavthomas/allura
    def pwd_expired_change(self, **kw):
        require_authenticated()
        return_to = kw.get('return_to')
        kw = F.password_change_form.to_python(kw, None)
        ap = plugin.AuthenticationProvider.get(request)
        try:
            expired_username = session.get('expired-username')
            expired_user = M.User.query.get(username=expired_username) if expired_username else None
            ap.set_password(expired_user or c.user, kw['oldpw'], kw['pw'])
            expired_user.set_tool_data('allura', pwd_reset_preserve_session=session.id)
            expired_user.set_tool_data('AuthPasswordReset', hash='', hash_expiry='')  # Clear password reset token

        except wexc.HTTPUnauthorized:
            flash('Incorrect password', 'error')
            redirect(tg.url('/auth/pwd_expired', dict(return_to=return_to)))
        flash('Password changed')
        session.pop('pwd-expired', None)
        session['username'] = session.get('expired-username')
        session.pop('expired-username', None)

        session.save()
        h.auditlog_user('Password reset (via expiration process)')
        if return_to and return_to != request.url:
            redirect(return_to)
        else:
            redirect('/')
コード例 #2
0
ファイル: auth.py プロジェクト: joequant/allura
    def pwd_expired_change(self, **kw):
        require_authenticated()
        return_to = kw.get("return_to")
        kw = F.password_change_form.to_python(kw, None)
        ap = plugin.AuthenticationProvider.get(request)
        try:
            expired_username = session.get("expired-username")
            expired_user = M.User.query.get(username=expired_username) if expired_username else None
            ap.set_password(expired_user or c.user, kw["oldpw"], kw["pw"])
            expired_user.set_tool_data("allura", pwd_reset_preserve_session=session.id)
            expired_user.set_tool_data("AuthPasswordReset", hash="", hash_expiry="")  # Clear password reset token

        except wexc.HTTPUnauthorized:
            flash("Incorrect password", "error")
            redirect(tg.url("/auth/pwd_expired", dict(return_to=return_to)))
        flash("Password changed")
        session.pop("pwd-expired", None)
        session["username"] = session.get("expired-username")
        session.pop("expired-username", None)

        session.save()
        h.auditlog_user("Password reset (via expiration process)")
        if return_to and return_to != request.url:
            redirect(return_to)
        else:
            redirect("/")
コード例 #3
0
ファイル: project.py プロジェクト: apache/allura
 def check_phone_verification(self, pin, **kw):
     p = plugin.ProjectRegistrationProvider.get()
     request_id = session.get('phone_verification.request_id')
     number_hash = session.get('phone_verification.number_hash')
     res = p.check_phone_verification(c.user, request_id, pin, number_hash)
     if 'error' in res:
         res['error'] = jinja2.Markup.escape(res['error'])
         res['error'] = h.really_unicode(res['error'])
     return res
コード例 #4
0
ファイル: root.py プロジェクト: TimmGit/posy
 def clear(self):
     try:
         session.get('skip', set()).remove(self.name)
     except KeyError:
         pass
     session['settings'].pop(self.name, None)
     session.save()
     flash(_('Settings cleared'))
     redirect(self.url)
コード例 #5
0
ファイル: root.py プロジェクト: smarkm/ovm
 def index(self):
     result = None
     if session.get('username') is not None:
         user = DBSession.query(User).filter_by(user_name=session.get('username')).first()
         if user is not None and user.is_cloud():
             if session['cloud_only'] == True:
                 override_template(self.index, 'genshi:stackone.templates.clouddashboard')
         
     result = self.controller_impl.index()
     return dict(result)
コード例 #6
0
 def oauth_callback(self, **kw):
     client_id = config.get("github_importer.client_id")
     secret = config.get("github_importer.client_secret")
     if not client_id or not secret:
         return  # GitHub app is not configured
     oauth = OAuth2Session(client_id, state=session.get("github.oauth.state"))
     token = oauth.fetch_token(
         "https://github.com/login/oauth/access_token", client_secret=secret, authorization_response=request.url
     )
     c.user.set_tool_data("GitHubProjectImport", token=token["access_token"])
     redirect(session.get("github.oauth.redirect", "/"))
コード例 #7
0
ファイル: ControllerImpl.py プロジェクト: smarkm/ovm
    def post_logout(self, came_from=url('/')):
        try:
            if session.get('username'):
                UIUpdateManager().del_user_updated_entities(session['username'], session['group_names'])
                UIUpdateManager().del_user_updated_tasks(session['username'])
                TopCache().delete_usercache(session.get('auth'))

        except Exception as e:
            print_traceback()
            LOGGER.error(to_str(e))

        session.delete()
コード例 #8
0
ファイル: root.py プロジェクト: TimmGit/posy
    def index(self, *args, **kw):
        '''
        Find first not set up service
        '''
        for name, item in self.menu:
            if name in session.get('skip', set()):
                continue
            if name not in session.get('settings', {}):
                redirect(item.url)
        # Redirect to the first item in list
        # redirect(self.menu[0][1].url)

        # Redirect to the last item in list
        redirect(item.url)
コード例 #9
0
 def oauth_callback(self, **kw):
     client_id = config.get('github_importer.client_id')
     secret = config.get('github_importer.client_secret')
     if not client_id or not secret:
         return  # GitHub app is not configured
     oauth = OAuth2Session(
         client_id, state=session.get('github.oauth.state'))
     token = oauth.fetch_token(
         'https://github.com/login/oauth/access_token',
         client_secret=secret,
         authorization_response=request.url
     )
     c.user.set_tool_data('GitHubProjectImport',
                          token=token['access_token'])
     redirect(session.get('github.oauth.redirect', '/'))
コード例 #10
0
ファイル: CMSCloudXMLRPC.py プロジェクト: smarkm/ovm
 def get_all_instance_categories(self):
     try:
         return self.csep_service.get_all_instance_categories_db(session.get('servicepoint_id'))
     except Exception as ex:
         print_traceback()
         LOGGER.error(to_str(ex))
         raise ex
コード例 #11
0
ファイル: cc_campaign.py プロジェクト: sysnux/astportal
   def fetch(self, page, rows, sidx, sord, **kw):
      ''' Function called on AJAX request made by FlexGrid
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * int(rows)
      except:
         offset = 0
         page = 1
         rows = 25

      apps = DBSession.query(Campaign).filter(Campaign.deleted==None)
      total = 1 + apps.count() / rows
      column = getattr(Campaign, sidx)
      apps = apps.order_by(getattr(column,sord)()).offset(offset).limit(rows)
      rows = [ { 'id'  : a.cmp_id, 'cell': row(a) } for a in apps ]

      return dict(page=page, total=total, rows=rows)
コード例 #12
0
ファイル: application.py プロジェクト: sysnux/astportal
    def fetch(self, page, rows, sidx, sord, **kw):
        """ Function called on AJAX request made by FlexGrid
      Fetch data from DB, return the list of rows + total + current page
      """

        # Try and use grid preference
        grid_rows = session.get("grid_rows", None)
        if rows == "-1":  # Default value
            rows = grid_rows if grid_rows is not None else 25

        # Save grid preference
        session["grid_rows"] = rows
        session.save()
        rows = int(rows)

        try:
            page = int(page)
            rows = int(rows)
            offset = (page - 1) * int(rp)
        except:
            offset = 0
            page = 1
            rows = 25

        apps = DBSession.query(Application)
        total = apps.count()
        column = getattr(Application, sidx)
        apps = apps.order_by(getattr(column, sord)()).offset(offset).limit(rows)
        rows = [{"id": a.app_id, "cell": row(a)} for a in apps]

        return dict(page=page, total=total, rows=rows)
コード例 #13
0
ファイル: ordering.py プロジェクト: LamCiuLoeng/aeo
    def ajaxAddtoCart( self, **kw ):
        _id = kw.get( 'id', None ) or None
        if not _id : return {'flag' : 1 , 'msg' : 'No ID provided!'}

        try:
            items = session.get( 'items', [] )
            tmp = {
                   '_k' : "%s%s" % ( dt.now().strftime( "%Y%m%d%H%M%S" ), random.randint( 100, 10000 ) ) ,
                   'id' : _id,
                   }
            qs = []
            for qk, qv in self._filterAndSorted( "option_qty", kw ):
                if not qv : continue
                q, _ = qv.split( "|" )
                if not q.isdigit() : continue
                qs.append( int( q ) )
            tmp['qty'] = sum( qs ) if qs else 0

            p = qry( Product ).get( _id )
            tmp['values'], tmp['optionstext'] = self._formatKW( kw, p )
            items.append( tmp )
            session['items'] = items
            session.save()
            return {'flag' : 0 , 'total' : len( session['items'] )}
        except:
            traceback.print_exc()
            return {'flag' : 1, 'msg':'Error occur on the sever side!'}
コード例 #14
0
ファイル: ordering.py プロジェクト: LamCiuLoeng/aeo
    def ajaxSavetoCart( self, **kw ):
        _k = kw.get( "_k", None )
        if not _k : return {'flag' : 1 , 'msg' : 'No ID provided!'}

        try:
            items = session.get( 'items', [] )
            for index, item in enumerate( items ):
                if item['_k'] != _k : continue
                p = qry( Product ).get( item['id'] )
                item['values'], item['optionstext'] = self._formatKW( kw , p )
                qs = []
                for qk, qv in self._filterAndSorted( "option_qty", kw ):
                    if not qv : continue
                    q, _ = qv.split( "|" )
                    if not q.isdigit() : continue
                    qs.append( int( q ) )
                item['qty'] = sum( qs ) if qs else 0
                items[index] = item
                session['items'] = items
                session.save()
                return {'flag' : 0 , 'optionstext' : item['optionstext'], }
        except:
            traceback.print_exc()
            return {'flag' : 1 , 'msg' : 'Error occur on the sever side!'}
        return {'flag' : 1 , 'msg' : 'No such item!'}
コード例 #15
0
ファイル: cc_outcall.py プロジェクト: sysnux/astportal
   def outcall_fetch(self, page, rows, sidx, sord, cust_id, **kw):
      ''' Function called on AJAX request made by FlexGrid
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * int(rp)
      except:
         offset = 0
         page = 1
         rows = 25

      data = DBSession.query(Outcall, CDR) \
         .outerjoin(CDR, Outcall.uniqueid==CDR.uniqueid) \
         .filter(Outcall.cust_id==cust_id)

      total = 1 + data.count() / rows
      column = getattr(Outcall, sidx)
      data = data.order_by(getattr(column,sord)()).offset(offset).limit(rows)
      rows = [ 
         { 'id'  : a.Outcall.out_id, 'cell': outcall_row(a) } for a in data ]

      return dict(page=page, total=total, rows=rows)
コード例 #16
0
ファイル: cc_outcall.py プロジェクト: sysnux/astportal
   def customer_fetch(self, page, rows, sidx, sord, cmp_id, **kw):
      ''' Function called on AJAX request made by FlexGrid
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * int(rows)
      except:
         offset = 0
         page = 1
         rows = 25

      data = DBSession.query(Customer). \
         filter(Customer.cmp_id==cmp_id). \
         filter(Customer.active==True)
      total = 1 + data.count() / rows
      column = getattr(Customer, sidx if sidx!='name' else 'lastname')
      data = data.order_by(getattr(column,sord)()).offset(offset).limit(rows)
      rows = [ { 'id'  : a.cust_id, 'cell': customer_row(a) } for a in data ]

      return dict(page=page, total=total, rows=rows)
コード例 #17
0
ファイル: phonebook.py プロジェクト: sysnux/astportal
   def fetch(self, page, rows, sidx='lastname', sord='asc', _search='false',
          searchOper=None, searchField=None, searchString=None, **kw):
      ''' Function called on AJAX request made by Grid JS component
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * rows
      except:
         offset = 0
         page = 1
         rows = 25

      pb = sorted(phonebook_list(request.identity['user'].user_id,
                         searchOper,
                         searchField,
                         searchString),
                  key = itemgetter(sidx),
                  reverse = True if sord=='desc' else False)
      total = len(pb)/rows+1
      data = [ { 'id'  : b['pb_id'], 'cell': row(b) } for b in pb[offset:offset+rows] ]

      return dict(page=page, total=total, rows=data)
コード例 #18
0
ファイル: EmailService.py プロジェクト: hewei-chn/openconvirt
    def send_email_to_user(self, msg):
        # Query sender and password from email credential table
        # Query mail_server,port,use_secure from the email setup table for curenly  logged in user
        # receiver: to be queried from users table
        self.msg = msg
        curr_user_id = session.get("userid")
        # query users table to retrieve email address of currenlt logged in user
        userRecord = DBSession.query(User.email_address).filter(User.user_name == curr_user_id).first()
        if userRecord:
            self.receivers = userRecord.email_address
        emailservers = self.get_mailservers()
        for eachmailserver in emailservers:
            if eachmailserver:
                self.mail_server = eachmailserver["MailSetup"].mail_server
                self.port = int(eachmailserver["MailSetup"].port)
                self.secure_type = int(eachmailserver["MailSetup"].use_secure)
                self.cred_details = eachmailserver["Creds"].cred_details
                self.password = self.cred_details["password"]
                self.sender = self.cred_details["user_email"]
                result = False
                if self.secure_type == NONSECURE:
                    result = EmailManager().send_nonsecure(
                        self.mail_server, self.port, self.sender, self.receivers, msg
                    )
                elif self.secure_type == TLS:
                    result = EmailManager().send_tls(
                        self.mail_server, self.port, self.sender, self.password, self.receivers, msg
                    )
                else:
                    result = EmailManager().send_ssl(
                        self.mail_server, self.port, self.sender, self.password, self.receivers, msg
                    )

                if result == True:
                    return "Test mail sent from " + eachmailserver["MailSetup"].mail_server
コード例 #19
0
ファイル: queues.py プロジェクト: sysnux/astportal
   def fetch(self, page, rows, sidx='name', sord='desc', _search='false',
          searchOper=None, searchField=None, searchString=None, **kw):
      ''' Function called on AJAX request made by Grid JS component
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * rows
      except:
         offset = 0
         page = 1
         rows = 25

      queue = DBSession.query(Queue)
      total = queue.count()/rows + 1
      column = getattr(Queue, sidx)
      queue = queue.order_by(getattr(column,sord)()).offset(offset).limit(rows)
      data = [ { 'id'  : q.queue_id, 'cell': row(q) } for q in queue ]

      return dict(page=page, total=total, rows=data)
コード例 #20
0
ファイル: trackhub.py プロジェクト: bbcf/biorepo
    def index(self, *args, **kw):
        user = handler.user.get_user_in_session(request)
        user_lab = session.get("current_lab", None)
        mail = user.email
        mail_tmp = mail.split("@")
        mail_final = mail_tmp[0] + "AT" + mail_tmp[1]
        user_TH_path = trackhubs_path() + "/" + user_lab + "/" + mail_final
        trackhubs = []
        if os.path.exists(user_TH_path):
            list_trackhubs = os.listdir(user_TH_path)
            for t in list_trackhubs:
                th_path = user_TH_path + "/" + t
                #the only one directory into at this th level is named by the assembly used for it
                for i in os.listdir(th_path):
                    path_to_test = th_path + "/" + i
                    if os.path.isdir(path_to_test):
                        assembly = i
                if not assembly:
                    break
                else:
                    #hub_url = th_path + "/hub.txt"
                    hostname = socket.gethostname().lower()
                    #because of aliasing
                    if hostname == "ptbbsrv2.epfl.ch":
                        hostname = "biorepo.epfl.ch"
                    hub_url = "http://" + hostname + url("/trackHubs/") + user_lab + "/" + mail_final + "/" + t + "/hub.txt"
                    th = Trackhub(t, 'http://genome.ucsc.edu/cgi-bin/hgTracks?hubUrl=' + hub_url + "&db=" + assembly)
                    trackhubs.append(th)

        all_trackhubs = [util.to_datagrid(TrackhubGrid(), trackhubs, " UCSC's Trackhub(s)", len(trackhubs) > 0)]

        return dict(page='trackhubs', model=trackhubs, items=all_trackhubs, value=kw)
コード例 #21
0
    def diff(self, commit, fmt=None, **kw):
        try:
            path, filename = os.path.split(self._blob.path())
            a_ci = c.app.repo.commit(commit)
            a = a_ci.get_path(self._blob.path())
            apath = a.path()
        except:
            a = []
            apath = ''
        b = self._blob

        if not self._blob.has_html_view:
            diff = "Cannot display: file marked as a binary type."
            return dict(a=a, b=b, diff=diff)

        la = list(a)
        lb = list(b)
        adesc = (u'a' + h.really_unicode(apath)).encode('utf-8')
        bdesc = (u'b' + h.really_unicode(b.path())).encode('utf-8')

        if not fmt:
            fmt = web_session.get('diformat', '')
        else:
            web_session['diformat'] = fmt
            web_session.save()
        if fmt == 'sidebyside':
            hd = HtmlSideBySideDiff()
            diff = hd.make_table(la, lb, adesc, bdesc)
        else:
            diff = ''.join(difflib.unified_diff(la, lb, adesc, bdesc))
        return dict(a=a, b=b, diff=diff)
コード例 #22
0
ファイル: moh.py プロジェクト: sysnux/astportal
   def fetch(self, page, rows, sidx='user_name', sord='asc', _search='false',
          searchOper=None, searchField=None, searchString=None, **kw):
      ''' Function called on AJAX request made by FlexGrid
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * rows
      except:
         offset = 0
         page = 1
         rows = 25

      sounds = DBSession.query(Sound)

      total = sounds.count()/rows + 1
      column = getattr(Sound, sidx)
      sounds = sounds.order_by(getattr(column,sord)()).offset(offset).limit(rows)
      rows = [ { 'id'  : s.sound_id, 'cell': row(s) } for s in sounds ]

      return dict(page=page, total=total, rows=rows)
コード例 #23
0
ファイル: root.py プロジェクト: bbcf/biorepo
    def search_to_json(self, *args, **kw):
        #TODO : sort by column on user's click
        user_lab = session.get("current_lab", None)
        #get parameters from ajax request
        search_value = kw.get("search[value]", None)
        if search_value == '':
            search_value = None
        #word lenght > 2 to avoid DDoS in your server....
        elif search_value is not None:
            list_search_words = [x for x in search_value.split(" ") if len(x) > 2]

        draw = int(kw.get("draw", 1))
        start_point = int(kw.get("start", 0))
        data_by_page = int(kw.get("length", 50))
        stop_point = start_point + data_by_page

        if user_lab:
            lab = DBSession.query(Labs).filter(Labs.name == user_lab).first()
            measurements_total = DBSession.query(Measurements).join(Measurements.attributs).filter(and_(Attributs.lab_id == lab.id, Attributs.deprecated == False)).all()
            measurements = DBSession.query(Measurements).join(Measurements.attributs).filter(and_(Attributs.lab_id == lab.id, Attributs.deprecated == False)).distinct()[start_point:stop_point]
            if search_value is not None:
                final_request = self.search_engine(list_search_words, lab)
                #query mixed with results from all the table of interest
                paginated_request = final_request[start_point:stop_point]
                searching_tosort = [SW(meas).to_json_test() for meas in paginated_request]
                searching = sorted(searching_tosort, key=lambda k: (k['User'], k['Type']))
                return json.dumps({"draw": draw, "recordsTotal": len(measurements_total), "recordsFiltered": len(final_request), "data": searching})

            searching_tosort = [SW(meas).to_json_test() for meas in measurements]
            searching = sorted(searching_tosort, key=lambda k: (k['User'], k['Type']))

        return json.dumps({"draw": draw, "recordsTotal": len(measurements_total), "recordsFiltered": len(measurements_total), "data": searching})
コード例 #24
0
ファイル: EmailService.py プロジェクト: smarkm/ovm
 def send_email_to_user(self, msg):
     self.msg = msg
     curr_user_id = session.get('userid')
     userRecord = DBSession.query(User.email_address).filter(User.user_name == curr_user_id).first()
     if userRecord:
         self.receivers = userRecord.email_address
     emailservers = self.get_mailservers()
     for eachmailserver in emailservers:
         if eachmailserver:
             self.mail_server = eachmailserver['MailSetup'].mail_server
             self.port = int(eachmailserver['MailSetup'].port)
             self.secure_type = int(eachmailserver['MailSetup'].use_secure)
             self.cred_details = eachmailserver['Creds'].cred_details
             self.password = self.cred_details['password']
             self.sender = self.cred_details['user_email']
             result = False
             if self.secure_type == NONSECURE:
                 result = EmailManager().send_nonsecure(self.mail_server, self.port, self.sender, self.receivers, msg)
             else:
                 if self.secure_type == TLS:
                     result = EmailManager().send_tls(self.mail_server, self.port, self.sender, self.password, self.receivers, msg)
                 else:
                     result = EmailManager().send_ssl(self.mail_server, self.port, self.sender, self.password, self.receivers, msg)
             if result == True:
                 return 'Test mail sent from ' + eachmailserver['MailSetup'].mail_server
コード例 #25
0
ファイル: datagrids.py プロジェクト: bbcf/biorepo
def build_columns():
    list_columns = [
            {"title": "", "data": "scroll_info"},
            {"title": "Description", "data": "Description", "defaultContent": ""},
            {"title": "User", "data": "User", "defaultContent": ""},
            {"title": "Projects", "data": "Projects", "defaultContent": ""},
            {"title": "Samples", "data": "Samples", "defaultContent": ""},
            {"title": "Type", "data": "Type", "defaultContent": ""},
            {"title": "Measurements", "data": "Measurements", "defaultContent": ""},
            #6
            {"title": "DataType", "data": "DataType", "defaultContent": ""},
            {"title": "Attachment", "data": "Attachment", "defaultContent": ""},
            {"title": "Created", "data": "Created", "defaultContent": ""},
            {"title": "Actions", "data": "Actions", "defaultContent": ""}]
    dyn_fields = sorted(session.get("search_grid_fields", []))
    for d in dyn_fields:
        dic_column = {}
        d = d.replace("_", " ")
        d = d.capitalize()
        dic_column["title"] = d
        dic_column["data"] = d
        dic_column["defaultContent"] = ""
        #insert dynamic fields after "DataType" and before "Attachment"
        list_columns[6:6] = [dic_column]
    return list_columns
コード例 #26
0
ファイル: ControllerImpl.py プロジェクト: RDTeam/openconvirt
    def login(self, came_from=url('/')):
        """Start the user login."""
        if session.get('userid') is None and request.identity is not None:
            self.redirect_to(url('/user_logout'))
#        login_counter = request.environ['repoze.who.logins']
#        if login_counter > 0:
#            flash(_('Wrong credentials'), 'warning')
        return dict(page='login',came_from=came_from)
コード例 #27
0
ファイル: CMSCloudXMLRPC.py プロジェクト: smarkm/ovm
 def create_volume(self, name, size, zone, snapshot, vdc_name):
     try:
         csep_id = session.get('servicepoint_id')
         return self.csep_service.create_volume(name, size, zone, snapshot, csep_id, vdc_name)
     except Exception as ex:
         print_traceback()
         LOGGER.error(to_str(ex))
         raise ex
コード例 #28
0
ファイル: user.py プロジェクト: sysnux/astportal
   def set_prefs(self, menu=None):

      log.debug('menu -> %s' % menu)
      if menu is not None:
         grid_rows = session.get('grid_rows', None)
         session['menu'] = menu
         session.save()

      return dict(status='ok')
コード例 #29
0
ファイル: root.py プロジェクト: bbcf/biorepo
    def searchlists_to_json(self, *args, **kw):
        user_lab = session.get("current_lab", None)
        if user_lab:
            lab = DBSession.query(Labs).filter(Labs.name == user_lab).first()
            one_meas = DBSession.query(Measurements).join(Measurements.attributs).filter(and_(Attributs.lab_id == lab.id, Attributs.deprecated == False)).first()
            search_grid, hidden_positions, positions_not_searchable = build_search_grid(one_meas)
            searchlists = json.dumps([hidden_positions, positions_not_searchable])

            return searchlists
コード例 #30
0
ファイル: root.py プロジェクト: vigilo/vigiboard
    def event(self, idevent, page):
        """
        Affichage de l'historique d'un événement brut.
        Pour accéder à cette page, l'utilisateur doit être authentifié.

        @param idevent: identifiant de l'événement brut souhaité.
        @type idevent: C{int}
        @param page: numéro de la page à afficher.
        @type page: C{int}

        Cette méthode permet de satisfaire l'exigence
        VIGILO_EXIG_VIGILO_BAC_0080.
        """

        # Auto-supervision
        self.get_failures()

        user = get_current_user()
        events = VigiboardRequest(user, False)
        events.add_table(
            Event,
            events.items.c.hostname.label('hostname'),
            events.items.c.servicename.label('servicename'),
        )
        events.add_join((EVENTSAGGREGATE_TABLE, \
            EVENTSAGGREGATE_TABLE.c.idevent == Event.idevent))
        events.add_join((CorrEvent, CorrEvent.idcorrevent == \
            EVENTSAGGREGATE_TABLE.c.idcorrevent))
        events.add_join((events.items,
            Event.idsupitem == events.items.c.idsupitem))
        events.add_filter(Event.idevent == idevent)

        if events.num_rows() != 1:
            flash(_('No such event or access denied'), 'error')
            redirect('/')

        events.format_events(0, 1)
        events.generate_tmpl_context()
        history = events.format_history()

        # Pagination des résultats
        items_per_page = int(session.get('items_per_page', config['vigiboard_items_per_page']))
        page = paginate.Page(history, page=page, items_per_page=items_per_page)
        event = events.req[0]

        return dict(
            idevent = idevent,
            hostname = event.hostname,
            servicename = event.servicename,
            plugins_data = {},
            page = page,
            search_form = create_search_form,
            search = {},
            fixed_search = {},
        )