Attention une mise à jour du service Gitlab va être effectuée le mardi 14 décembre entre 13h30 et 14h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

admin.py 1.26 KB
Newer Older
Marc Duez's avatar
Marc Duez committed
1 2
# coding: utf8
import gluon.contrib.simplejson
Marc Duez's avatar
Marc Duez committed
3
import os.path
4

Marc Duez's avatar
Marc Duez committed
5 6 7 8 9 10 11 12
if request.env.http_origin:
    response.headers['Access-Control-Allow-Origin'] = request.env.http_origin  
    response.headers['Access-Control-Allow-Credentials'] = 'true'
    response.headers['Access-Control-Max-Age'] = 86400
    

## return admin_panel
def index():
13 14
    if auth.has_membership("admin"):
        return dict(message=T(''))
Marc Duez's avatar
Marc Duez committed
15 16 17 18
    
def worker():
    if auth.has_membership("admin"):
        return dict(message=T(''))
Marc Duez's avatar
Marc Duez committed
19 20 21 22 23 24 25 26 27 28 29 30 31

## to use after change in the upload folder
def repair_missing_files():
    if auth.has_membership("admin"):
        
        flist = ""
        for row in db(db.sequence_file.id>0 and db.sequence_file.data_file != None).select() : 
            seq_file = defs.DIR_SEQUENCES+row.data_file
            
            if not os.path.exists(seq_file) :
                db.sequence_file[row.id] = dict(data_file = None)
                flist += " : " + row.filename
            else :
32
                size = os.path.getsize(seq_file)
Marc Duez's avatar
Marc Duez committed
33 34 35 36
                db.sequence_file[row.id] = dict(size_file = size)
                
        res = {"success" : "true", "message" : "path of missing files have been removed from the database"+flist}
        return gluon.contrib.simplejson.dumps(res, separators=(',',':'))