예제 #1
0
def issuer_create_submit():
    name = request.params.name
    description = request.params.description
    url = request.params.url
    if (request.get_cookie('loggedin')):
        useremail = request.get_cookie('loggedin', secret='applesauce')
        userbadges = m3.get_users_badges(pcrDB, useremail)
        issuers = m3.get_issuers(pcrDB)
        if (m3.find_issuer(pcrDB, name) != None):
            return template('base.tpl', title='PCR Hero',
                            email=useremail) + '''\
                <h1>Welcome to PCR Hero's Admin Menu - {}</h1> <p style="color:red;">Sorry, that issuer is taken!</p>
            '''.format(useremail) + template('admin-issuer.tpl',
                                             badges=userbadges,
                                             issuers=issuers) + "</body>"
        else:
            newIssuer = m3.PCRIssuer(name, description, url)
            m3.add_issuer(pcrDB, newIssuer)
            newIssuer.establish_here()
            issuers = m3.get_issuers(pcrDB)
            return template('base.tpl', title='PCR Hero',
                            email=useremail) + '''\
                <h1>Welcome to PCR Hero's Admin Menu - {}</h1> <p style="color:blue;">Your issuer has been created!</p>
            '''.format(useremail) + template('admin-issuer.tpl',
                                             badges=userbadges,
                                             issuers=issuers) + "</body>"
    else:
        redirect("/login")
예제 #2
0
파일: hello4.py 프로젝트: jsjdesign/PCRHero
def badge_submit():
    if(request.get_cookie('loggedin')):
        useremail = request.get_cookie('loggedin', secret='applesauce')
        userbadges = m3.get_users_badges(pcrDB, useremail)
        issuers = m3.get_issuers(pcrDB)
        image_path = "/home/ubuntu/pythonproject/images"
        available_images = os.listdir(image_path)
        
        ## return args
        name = request.params.name
        if(m3.find_badge(pcrDB, name) != None):
            return template('base.tpl', title='PCR Hero', email= useremail) + '''\
                <h1>Welcome to PCR Hero's Admin Menu - {}</h1>
                <h2 style="color:red">A badge with that name already exists!</h2>
            '''.format(useremail) + template('admin-badge.tpl', badges=userbadges, issuers=issuers, images=available_images) + "</body>"

        else:
            description = request.params.description
            image = request.params.image
            criteria = request.params.criteria
            tags = request.params.tags
            issuer = request.params.issuer

            newBadge = m3.OpenBadge(name, description, image, criteria, tags, issuer)
            newBadge.establish_here()
            newBadge.add_badge(pcrDB)

            return template('base.tpl', title='PCR Hero', email= useremail) + '''\
                <h1>Welcome to PCR Hero's Admin Menu - {}</h1>
                <h2 style="color:blue">Your badge was successfully created!</h2>
            '''.format(useremail) + template('admin-badge.tpl', badges=userbadges, issuers=issuers, images=available_images) + "</body>"

    else:
        redirect("/login")
예제 #3
0
def badge_submit():
    if(request.get_cookie('loggedin')):
        useremail = request.get_cookie('loggedin', secret='applesauce')
        userbadges = m3.get_users_badges(pcrDB, useremail)
        issuers = m3.get_issuers(pcrDB)
        image_path = "/home/ubuntu/pythonproject/images"
        available_images = os.listdir(image_path)
        
        ## return args
        name = request.params.name
        if(m3.find_badge(pcrDB, name) != None):
            return template('base.tpl', title='PCR Hero', email= useremail) + '''\
                <h1>Welcome to PCR Hero's Admin Menu - {}</h1>
                <h2 style="color:red">A badge with that name already exists!</h2>
            '''.format(useremail) + template('admin-badge.tpl', badges=userbadges, issuers=issuers, images=available_images) + "</body>"

        else:
            description = request.params.description
            image = request.params.image
            criteria = request.params.criteria
            tags = request.params.tags
            issuer = request.params.issuer

            newBadge = m3.OpenBadge(name, description, image, criteria, tags, issuer)
            newBadge.establish_here()
            newBadge.add_badge(pcrDB)

            return template('base.tpl', title='PCR Hero', email= useremail) + '''\
                <h1>Welcome to PCR Hero's Admin Menu - {}</h1>
                <h2 style="color:blue">Your badge was successfully created!</h2>
            '''.format(useremail) + template('admin-badge.tpl', badges=userbadges, issuers=issuers, images=available_images) + "</body>"

    else:
        redirect("/login")
예제 #4
0
파일: hello4.py 프로젝트: jsjdesign/PCRHero
def issuer_create_menu():
    if(request.get_cookie('loggedin')):
        useremail = request.get_cookie('loggedin', secret='applesauce')
        userbadges = m3.get_users_badges(pcrDB, useremail)
        issuers = m3.get_issuers(pcrDB)
        return template('base.tpl', title='PCR Hero', email= useremail) + '''\
            <h1>Welcome to PCR Hero's Admin Menu - {}</h1>
        '''.format(useremail) + template('admin-issuer.tpl', badges=userbadges, issuers=issuers) + "</body>"
    else:
        redirect("/login")
예제 #5
0
def issuer_create_menu():
    if(request.get_cookie('loggedin')):
        useremail = request.get_cookie('loggedin', secret='applesauce')
        userbadges = m3.get_users_badges(pcrDB, useremail)
        issuers = m3.get_issuers(pcrDB)
        return template('base.tpl', title='PCR Hero', email= useremail) + '''\
            <h1>Welcome to PCR Hero's Admin Menu - {}</h1>
        '''.format(useremail) + template('admin-issuer.tpl', badges=userbadges, issuers=issuers) + "</body>"
    else:
        redirect("/login")
예제 #6
0
파일: hello4.py 프로젝트: jsjdesign/PCRHero
def badge_menu():
    if(request.get_cookie('loggedin')):
        useremail = request.get_cookie('loggedin', secret='applesauce')
        userbadges = m3.get_users_badges(pcrDB, useremail)
        issuers = m3.get_issuers(pcrDB)
        image_path = "/home/ubuntu/pythonproject/images"
        available_images = os.listdir(image_path)
        return template('base.tpl', title='PCR Hero', email= useremail) + '''\
            <h1>Welcome to PCR Hero's Admin Menu - {}</h1>
        '''.format(useremail) + template('admin-badge.tpl', badges=userbadges, issuers=issuers, images=available_images) + "</body>"
    else:
        redirect("/login")
예제 #7
0
def badge_menu():
    if(request.get_cookie('loggedin')):
        useremail = request.get_cookie('loggedin', secret='applesauce')
        userbadges = m3.get_users_badges(pcrDB, useremail)
        issuers = m3.get_issuers(pcrDB)
        image_path = "/home/ubuntu/pythonproject/images"
        available_images = os.listdir(image_path)
        return template('base.tpl', title='PCR Hero', email= useremail) + '''\
            <h1>Welcome to PCR Hero's Admin Menu - {}</h1>
        '''.format(useremail) + template('admin-badge.tpl', badges=userbadges, issuers=issuers, images=available_images) + "</body>"
    else:
        redirect("/login")
예제 #8
0
파일: hello4.py 프로젝트: jsjdesign/PCRHero
def issuer_create_submit():
    name = request.params.name
    description = request.params.description
    url = request.params.url
    if(request.get_cookie('loggedin')):
        useremail = request.get_cookie('loggedin', secret='applesauce')
        userbadges = m3.get_users_badges(pcrDB, useremail)
        issuers = m3.get_issuers(pcrDB)
        if(m3.find_issuer(pcrDB, name) != None):
            return template('base.tpl', title='PCR Hero', email= useremail) + '''\
                <h1>Welcome to PCR Hero's Admin Menu - {}</h1> <p style="color:red;">Sorry, that issuer is taken!</p>
            '''.format(useremail) + template('admin-issuer.tpl', badges=userbadges, issuers=issuers) + "</body>"
        else:
            newIssuer = m3.PCRIssuer(name, description, url)
            m3.add_issuer(pcrDB, newIssuer)
            newIssuer.establish_here()
            issuers = m3.get_issuers(pcrDB)
            return template('base.tpl', title='PCR Hero', email= useremail) + '''\
                <h1>Welcome to PCR Hero's Admin Menu - {}</h1> <p style="color:blue;">Your issuer has been created!</p>
            '''.format(useremail) + template('admin-issuer.tpl', badges=userbadges, issuers=issuers) + "</body>"
    else:
        redirect("/login")