Пример #1
0
def init_db_data():
    user = Shared.getLoggedInUser()
    if user is not None:
        if user.utype == 1:
            pass

    return abort(403)
Пример #2
0
def dashboard():

    error = None
    completedExps = None
    u = None
    try:
        if Shared.isLoggedIn():

            import models
            u = Shared.getLoggedInUser()

            exps = models.Experiment.query.filter_by(userId=int(session['u']))
            completedExps = exps.filter(
                Experiment.endDateTime != '--RUNNING--')
            cDataSets = [
                json.loads(ce.pars)['datasets'] for ce in completedExps
            ]

            md5Names = [
                ExpDA.generateViolinPlots(cexp) for cexp in completedExps
            ]
            plotFiles = [[
                '/static/plots/' + m + '/' + file
                for file in os.listdir(config.plotsPath + m)
                if file.endswith('.svg') and file.startswith('Method')
            ] for m in md5Names]
            runningExps = exps.filter(Experiment.endDateTime == '--RUNNING--')
            runningValid = []
            for r in runningExps:
                pid = json.loads(r.pars)['pid']
                if not Security.check_pid(pid):
                    runningValid.append(False)
                else:
                    runningValid.append(True)
                    #r.delete()
                    #db.session.commit()
            return render_template('users/dashboard.html',
                                   error=error,
                                   completedExps=completedExps,
                                   u=u,
                                   runningExps=runningExps,
                                   cDataSets=cDataSets,
                                   plotFiles=plotFiles,
                                   runningValid=runningValid)
    except Exception as exep:
        file = open('error.txt', 'w')
        file.write(str(exep))
        file.close()

    return redirect(url_for('BPUsers.login'))
Пример #3
0
def myrepos():

    error = None
    completedClones = None
    u = None
    if Shared.isLoggedIn():

        u = Shared.getLoggedInUser()
        repos = Repo.query.filter_by(userId=int(session['u']))
        completedClones = repos.filter(Repo.cloneFinishDate != '--RUNNING--')
        runningClones = repos.filter(Repo.cloneFinishDate == '--RUNNING--')

        return render_template('expr/szz/myrepos.html',
                               error=error,
                               completedClones=completedClones,
                               u=u,
                               runningClones=runningClones)
    return redirect(url_for('BPUsers.login'))
Пример #4
0
def submit_comment_reply():

    message = None
    if request.method == 'POST':

        isAnonym = True
        data = json.loads(request.data)
        commentText = data['replyText']
        inReplyTo = int(data['id'])
        commentorId = 0
        postId = int(data['postId'])

        if Shared.isLoggedIn():
            #return redirect(url_for('index'))
            user = Shared.getLoggedInUser()
            isAnonym = False
            name = user.name
            email = user.email
            commentorId = user.id
        else:
            name = 'Anonym'
            email = ''
            commentorId = 0

        pc = PostComment()
        pc.commentorEmail = email
        pc.commentorName = name
        pc.commentText = commentText
        pc.commentorId = commentorId
        pc.inReplyTo = inReplyTo
        pc.postId = postId
        pc.commentDate = Common.getCurrentTimeMil()

        db.session.add(pc)
        db.session.commit()
        resp = make_response(
            render_template('blog/singleComment.html', comment=pc))
        return json.dumps({
            'html': resp.data.decode("utf-8"),
            "id": str(inReplyTo)
        })
        #else:
        #    return render_template('blog/singleComment.html', comment = pc)
    return ""
Пример #5
0
def clonerepo():
    error = None
    ret = None

    if Shared.isLoggedIn():
        if request.method == 'POST':
            url = None
            repoName = None
            isPrivate = False
            uid = Shared.getLoggedInUser().id
            try:
                pars = {
                    'url': request.form['url'],
                    'repoName': request.form['repoName'],
                    'isPrivate': 'isPrivate' in request.form,
                    'uid': uid
                }

            except Exception as e:
                error = str(e)
                print(error)
                return render_template('expr/szz/clonerepo.html', error=error)
            try:

                #RunWithPars(pars,uid)

                p = mp.Process(target=RunWithPars, args=(pars, uid))
                p.start()
                ret = 'Scheduled. Check the cloning status in your repository page.'
                error = None
            except Exception as ex:
                error = str(ex)
                ret = None

        return render_template('expr/szz/clonerepo.html',
                               error=error,
                               result=ret)
    else:
        error = 'You are not logged in'
        return redirect(url_for('BPUsers.login'))
    return render_template('expr/szz/clonerepo.html')
Пример #6
0
def create_post():
    if not Shared.isLoggedIn():
        return redirect(url_for('index'))
    user = Shared.getLoggedInUser()
    if user.utype != 1:
        print('Not authorised to access')
        return redirect(url_for('index'))

    message = None
    if request.method == 'POST':
        title = request.form.get('title')
        body = request.form.get('ckeditor')
        bp = BlogPost()
        bp.postBody = body
        bp.postTitle = title
        bp.postDate = Common.getCurrentTimeMil()
        bp.postCreatorId = user.id
        bp.postPerms = 0
        bp.viewCount = 0
        db.session.add(bp)
        db.session.commit()
        message = 'Post Saved Successfully'
        return redirect(url_for('BPBlog.posts'))
    return render_template('blog/create_post.html', message=message)
Пример #7
0
def index():
    """
    Start page
    """
    u = Shared.getLoggedInUser()               
    return render_template("index.html",  u = u)
Пример #8
0
def viewpost(id):

    if request.method == 'POST':
        if 'formAddComment' in request.form:
            name, email = None, None
            commentorId = 0
            if not Shared.isLoggedIn():
                name = request.form['commentorName']
                email = request.form['commentorEmail']

            else:
                user = Shared.getLoggedInUser()
                name = user.name
                email = user.email
                commentorId = user.id
            commentText = request.form['commentText']

            pc = PostComment()
            pc.commentorEmail = email
            pc.commentorName = name
            pc.commentText = commentText
            pc.commentorId = commentorId
            pc.inReplyTo = 0
            pc.postId = id
            pc.commentDate = Common.getCurrentTimeMil()

            db.session.add(pc)
            db.session.commit()

    post = BlogPost.query.filter_by(id=id).first()
    comments = PostComment.query.filter_by(postId=id)

    #if comments.count()<=0:
    #    comments = None

    commentsDict = None
    commentReplies = None
    if comments:
        commentsDict = {comment.id: comment for comment in comments}
        commentReplies = {}
        #ht = ""

        for comment in comments:
            commentReplies[comment.id] = []

        for comment in comments:
            if comment.inReplyTo == 0:
                continue
            commentReplies[comment.inReplyTo].append(comment)
            #if comment.inReplyTo == 0:

            #    parents.append(comment)
            #    p = 0
            #    ht+='<div class="row">'+ comment.commentText +'<a href="reply('+str(comment.id)+')" class="replyfont"> Reply </a>'+'</div>'
            #    ht = checkChilds(comment,ht,comments, p)
            #else:
            #    depths[comment.id] = depths[comment.inReplyTo]+1

    return render_template(
        'blog/viewpost.html',
        post=post,
        comments=comments,
        commentsDict=commentsDict,
        commentReplies=commentReplies)  # comments = comments, ht = ht)