Exemplo n.º 1
0
 def get_kws_mgt_kws_info(self, kws_id):
     ps = PropStore()
     ps.kws_id = kws_id
     ps.org_name = ""
     ps.user_list = []
     
     cur = db_session.execute(("SELECT creation_date, name FROM kcd_kws_list WHERE kws_id = %i") % (kws_id))
     row = cur.fetchone()
     if row == None: raise ErrorMsg("Teambox %i not found" % (kws_id))
     ps.creation_date = row["creation_date"]
     ps.name = ltu(row["name"])
     cur.close()
     
     cur = db_session.execute(("SELECT file_size, file_quota FROM kcd_kws_kfs_limit WHERE kws_id = %i") % (kws_id))
     row = cur.fetchone()
     if row == None: raise ErrorMsg("Teambox %i not found" % (kws_id))
     ps.file_quota = row["file_quota"]
     ps.file_size = row["file_size"]
     cur.close()
     
     cur = db_session.execute(("SELECT user_id, email, name_admin, name_user, org_name FROM " +\
                               "kcd_kws_users WHERE kws_id = %i ORDER BY user_id") % (kws_id))
     for row in cur.fetchall():
         user = PropStore()
         user.user_id = row["user_id"]
         user.email = ltu(row["email"])
         if row["name_admin"] != "": user.name = ltu(row["name_admin"])
         elif row["name_user"] != "": user.name = ltu(row["name_user"])
         else: user.name = ""
         user.org_name = ltu(row["org_name"])
         ps.user_list.append(user)
     db_session.rollback()
     if len(ps.user_list): ps.org_name = ps.user_list[0].org_name
     return ps
Exemplo n.º 2
0
 def get_kws_mgt_nb_kws(self):
     cur = db_session.execute("SELECT count(kws_id) FROM kcd_kws_list WHERE (flags & %d = 0)" %\
                              (KANP_KWS_FLAG_DELETE))
     row = cur.fetchone()
     if not row: raise Exception("cannot get number of Teamboxes")
     nb_kws = row[0]
     db_session.rollback()
     return nb_kws
Exemplo n.º 3
0
 def get_kws_mgt_kws_list(self, offset, limit):
     l = []
     cur = db_session.execute(("SELECT kws_id FROM kcd_kws_list WHERE (flags & %d = 0) " +\
                               "ORDER BY kws_id OFFSET %i LIMIT %i") % \
                              (KANP_KWS_FLAG_DELETE, offset, limit))
     for row in cur.fetchall(): l.append(row[0])
     db_session.rollback()
     return l
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
 def update_kws_quota(self, kws_id, quota):
     db_session.execute("UPDATE kcd_kws_kfs_limit SET file_quota = %i WHERE kws_id = %i" % (quota, kws_id))
     db_session.commit()