Beispiel #1
0
def edit(lecture_id):
    """Úprava specifické cvičení"""
    
    lecture = Lecture.get( lecture_id )
    form = LectureForm(request.forms.decode(), lecture)
    user = getUser()

    if not ( user.inRole("master") or lecture.lector == user.login):
        return unauthorized()

    if request.method == 'POST' and form.validate():
        try:
            lecture.update( name = form.name.data, nonterminal = form.nonterminal.data )
            msg("Cvičení aktualizováno","success")
        except Exception as e:
            msg("Chyba při aktualizaci - %s" % e, "error")
        
        redirect(request.path)    
        
    try:
        text =  lecture.generate() 
    except Exception as e:
        text = "Došlo k chybě : \n %s      \n %s" % (type(e).__name__, e)        
         
    return template("lectures_edit", {"lecture" : lecture, "form": form_renderer(form), "text": text } )    
Beispiel #2
0
def template(*args, **kwargs):
    """Vylepsená funkce pro volani sablony
    
        doplnuje zprávy ze sessions, aktualne prihlaseneho usera a menu
    """
    
    ### zprávy
     
    s = request.environ.get('beaker.session')
    msgs = s.get("msgs", tuple());
    kwargs["msgs"] = msgs
    if msgs:
        s.pop("msgs")
    
    ### uživatel
        
    from user import getUser        
    kwargs["user"] = getUser()
    
    ### menu
    kwargs["slug"] = slug
    kwargs["getMenu"] = _getMenu
    kwargs["requestedURL"] = request.path
    
    ### verze
    kwargs["VERSION_CONTROL"] = VERSION_CONTROL
    
        
    return bottle.template(*args, **kwargs) 
Beispiel #3
0
def assigmentCount():
    """ Vrácení počtu nevyřízených zadání, použito pro aktualizaci v menu"""
    usr = getUser() 
    if (not usr) or (not usr.inRole("lector")):
        return {"status" : "error", "count" : "!"}
        
    return { "status" : "ok", "count" : Assigment.getPendingCount(usr.login) }        
Beispiel #4
0
def login():
    """ Creates new user if needed. Then logs the user in. 
    Note:
        Stores phonenumber in a cookie
    
    """
    form = LoginForm()
    if request.method == "GET":
        return render_template("login.html",form=form)
    
    if form.validate_on_submit():
        #convert phonenumber to an integer
        phoneNumber = re.sub(r'[^0-9]','',str(form.number.data))
        phoneNumer = int(phoneNumber)
        
        hashPhone = hashVal(phoneNumber)
        user = newUser(hashPhone)#none if user alreay exists
        note = "Successfully Loggedin."
        
        #user is trying to generate a password
        if user == None:
            user = getUser(hashPhone)
            flash(note)
            return redirect(url_for("getCode", phoneNumber = str(phoneNumber)))
        
        #user is creating an account
        note = "New Account created for " + str(phoneNumber) + ".\n" + note
        flash(note)
    return redirect(request.args.get("next") or url_for("login"))
Beispiel #5
0
def list():
    """Seznam cvičení"""
    
    usr = getUser() 
    
    
    if request.params.get("activate"):
        lec = Lecture.get( request.params.get("activate") )
        lec.activate()
        msg("Cvičení %s bylo zapnuto" % lec.name,"success")
        redirect(request.path)
        
    if request.params.get("deactivate"):
        lec = Lecture.get( request.params.get("deactivate") )
        lec.deactivate()
        msg("Cvičení %s bylo vypnuto" % lec.name,"success")
        redirect(request.path)        
    
    # vložení nového cvičení
    if request.forms.get("add"):
        lec = Lecture.insert( request.forms.decode().get("add"), usr.login )
        if lec:
            msg("Cvičení %s vytvořeno" % lec.name,"success")
            redirect("/lectures/edit/%i" % lec.lecture_id )
        else:
            msg("Chyba při vytváření cvičení","error")
            redirect(request.path)
        
    lectures = Lecture.getAll() if usr.inRole("master") else Lecture.getAll(usr.login) 
    
    return template("lectures", {"lectures" : lectures, "showLector": usr.inRole("master") } )
Beispiel #6
0
def assigmentRate(assigment_id):
    """Úprava a obodování zadání"""
    usr = getUser() 

    assigment = Assigment.get( assigment_id ) 
    if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno")
    #todo if ???: return HTTPError(403, "Nemáte oprávnění")

        

    if request.method == 'POST':
        action = request.forms.get("action")
        if (not action) or  (not action in ("lock", "rate", "unlock")): HTTPError(400, "Neznámá akce")
        print("----------action", action)
        try:
            if action == "lock":
                assigment.lock()
                msg("Řešení bylo zamčeno", "success")
            elif action == "rate":
                assigment.rate(  request.forms.get("points") )
                msg("Řešení bylo ohodnoceno", "success")
            elif action == "unlock":
                assigment.unlock()
                msg("Řešení bylo odemčeno", "success")            
        except ModelException as e:
            msg("Chyba při manipulaci: %s" %s, "error")             
        redirect('/assigments-lector')
        return

    return template("assigments_rate", {"assigment" : assigment } )
Beispiel #7
0
    def post(self):
        username = self.request.get("username")
        password =  self.request.get("password")
        args = {"name":username}
        err = False

        if not self.validUsername(username):
            args["nameerr"] = "Invalid username."
            err = True

        if not self.validPsw(password):
            args["pswerr"] = "Invalid password."
            err = True

        if err:
            self.write(**args)
            return

        u =  user.getUser(username)
        if (u):
            if u.check(password):
                userCookie = u.bake()                
                self.setUserCookie(userCookie)
                self.redirect(head.adr['welcome']); 
                return
            self.write(pswerr = "Incorrect password.",**args)
            return
        self.write(nameerr = "User not found.",**args)
Beispiel #8
0
    def getMembers(self, groupName=None, gidNumber=None,_dc=None,query=None):
        
        server = cherrypy.session['server']
        suffix = cherrypy.session['suffix']
        adminUser = cherrypy.session['username']
        adminPass = cherrypy.session['password']
        if not server or not suffix or not adminUser or not adminPass:
            doLogout('You cannot be here')
            return "{failure:1,'info':'Access violation: you are not logged in or your session has expired'}"
        
        if gidNumber:
            results = do_ldap_search("(&(objectclass=posixGroup)(gidNumber=%s))" % (gidNumber))
        elif groupName:
            results = do_ldap_search("(&(objectclass=posixGroup)(cn=%s))" % (groupName))
        if not results:
            return "{failure:1,'text':'No members found'}"

        if not results[0][0][1].has_key('memberUid'):
            return "{success:1,'text':'No members found'}"
        members=results[0][0][1]['memberUid']
        
        output="{results: ["
        for member in members:
            user_details = getUser(uidNumber=member)
            if user_details:
                output+="""{cn: '%s',gidNumber:%s,givenName:'%s',sn:'%s',uid:'%s'},""" % (getUserCN(member),member,
                                                                                          user_details['givenName'][0],
                                                                                          user_details['sn'][0],
                                                                                          user_details['uid'][0])
        output+="]}"
        
        cherrypy.response.headers['Content-Type'] = "text/plain"
        return output
Beispiel #9
0
def lectureMenu():
    usr = getUser() 

    if usr and usr.inRole("student"):
        addMenu("/assigments","Zadání",25)
        
    if usr and usr.inRole("lector"):
        addMenu("/assigments-lector","Zadání",10, Assigment.getPendingCount(usr.login) )        
Beispiel #10
0
def getCode(phoneNumber):
    phoneHash = hashVal(phoneNumber) 
    user = newUser(phoneHash)#none if user alreay exists
    if user == None:
        user = getUser(phoneHash)
    print(str(user))
    code = user.updateCode()
    print("Sending code value: " + str(code))
    sendCode(phoneNumber,code)
    return redirect(url_for("genCode",phoneNumber=str(phoneNumber)))
Beispiel #11
0
def list():
    """Seznam odevzdaných zadání"""
    
    usr = getUser() 
    #todo pro mastera zobrazit všechny

    # zjistíme v jaké jsme skupině
    assigments = Assigment.getPending( usr.login ) 
    silent = Assigment.getSilent( usr.login ) 
    
    return template("assigments_lector", {"assigments" : assigments, "silent" : silent, "showLector" : usr.inRole("master") } )
Beispiel #12
0
def list():
    """Seznam aktivních cvičení, na které se student může přihlásit"""
    
    usr = getUser() 

    # zjistíme v jaké jsme skupině
    grp = usr.getGroup()
    #todo: assert group != None
      
    lectures = Lecture.getAvailable( grp.lector ) 
    
    return template("assigments_student", {"lectures" : lectures, } )
Beispiel #13
0
def genCode(phoneNumber):
    user = getUser(hashVal(phoneNumber))
    print("Current user: "******"GET":
        return render_template("genCode.html",form=form)
    if form.validate_on_submit():
        #gen password
        if not user.checkCode(int(form.code.data)):
            flash("One time code does not match. Please try again.")
            return redirect(url_for("genCode",phoneNumber = str(phoneNumber)))
        password = user.genPass(form.url.data,True)
        flash("Password for " + form.url.data + " is " + str(password))
    return redirect(url_for("login"))
Beispiel #14
0
def assigmentDownload(assigment_id):
    """Stažení zadání"""
    usr = getUser() 

    assigment = Assigment.get( assigment_id ) 
    if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno")
    #todo if ???: return HTTPError(403, "Nemáte oprávnění")

    headers = {}
    headers['Content-Type'] = "text/txt"
    headers['Content-Disposition'] = 'attachment; filename="%s.asm"' % assigment.login

    data = assigment.response

    return HTTPResponse(data, **headers)
def list():
    """Seznam odevzdaných zadání"""

    usr = getUser()
    #todo pro mastera zobrazit všechny

    # zjistíme v jaké jsme skupině
    assigments = Assigment.getPending(usr.login)
    silent = Assigment.getSilent(usr.login)

    return template(
        "assigments_lector", {
            "assigments": assigments,
            "silent": silent,
            "showLector": usr.inRole("master")
        })
def assigmentDownload(assigment_id):
    """Stažení zadání"""
    usr = getUser()

    assigment = Assigment.get(assigment_id)
    if not assigment: return HTTPError(404, "Cvičení nebylo nalezeno")
    #todo if ???: return HTTPError(403, "Nemáte oprávnění")

    headers = {}
    headers['Content-Type'] = "text/txt"
    headers[
        'Content-Disposition'] = 'attachment; filename="%s.asm"' % assigment.login

    data = assigment.response

    return HTTPResponse(data, **headers)
def show(lecture_id):
    """Zobrazení a odevzdávání zadání """

    usr = getUser()
    lec = Lecture.get(lecture_id)

    if not lec: return HTTPError(404, "Cvičení nebylo nalezeno")

    if not lec.isActive():
        msg("Cvičení není aktivní", "error")
        redirect("/assigments")

    assigment = Assigment.getUnique(lecture_id, usr.login)

    if not assigment:
        assigment = Assigment.create(lec.lecture_id, lec.generate(), usr.login)
        msg("Cvičení bylo vygenerováno", "success")

    if request.method == 'POST' and request.files.response:
        try:
            assigment.respond(request.files.response.file.read())
            msgTxt = "Řešení bylo úspěšně odesláno"

            if request.is_xhr:
                return HTTPResponse({
                    "type": "success",
                    "msg": msgTxt
                })
            msg(msgTxt, "success")

        except Exception as e:
            msgTxt = "Chyba při odesílání řešení - %s" % e

            if request.is_xhr:
                return HTTPResponse({
                    "type": "error",
                    "msg": msgTxt
                })

            msg(msgTxt, "error")

        redirect(request.path)

    return template("assigments_show", {
        "assigment": assigment,
        "lecture": lec
    })
Beispiel #18
0
def edit(group_id):
    """Úprava specifické skupiny včetně přidávání uživatelů"""
    
    user = getUser()
    group = Group.get( group_id )
    
    if not ( user.inRole("master") or group.lector == user.login):
        return unauthorized()
    
    # vložení studenta
    if request.forms.get("add"):
        try:
            usr = User.insertStudent( request.forms.get("add"), group_id )
            msg("Student %s vložen" % usr.login,"success")
        except Exception as e: 
            msg("Chyba při vkládání studenta - %s " % e,"error")                   
                

        redirect(request.path)
    
    # odstranění studenta
    if request.query.get("remove"):
        usr = User.get( request.query.get("remove") )

        if not usr:
            msg("Student nenalezen","error")
        elif usr.remove():
            msg("Student %s odstraněn"% usr.login ,"success")
        else:
            msg("Student nenalezen","error")

        redirect(request.path)
        
    form = GroupForm(request.forms.decode(), group)
    
    if request.method == 'POST' and form.validate():
        try:
            group.update( name = form.name.data )
            msg("Skupina aktualizována","success")
        except Exception as e:
            msg("Chyba při aktualizaci - %s" % e, "error")
        
        redirect(request.path)    

    return template("groups_edit", {"group" : group, "form": form_renderer(form) } )
Beispiel #19
0
def delete(group_id):
    """Smaže skupinu"""

    user = getUser()
    group = Group.get( group_id )

    if not ( user.inRole("master") or group.lector == user.login):
        return unauthorized()

    answer = request.forms.get("answer") 
    if answer:
        if answer == "Ne": redirect("/groups")
        if answer == "Ano":
            group.remove()
            msg("Skupina smazána","success")
            redirect("/groups")
            
    return template("question", {"question":"Skutečně chcete smazat skupinu '%s'" % group.name } )            
Beispiel #20
0
def list():
    """Seznam skupin"""

    usr = getUser()

    # vložení nové skupiny
    if request.forms.get("add"):
        grp = Group.insert(request.forms.decode().get("add"), usr.login)
        if grp:
            msg("Skupina %s vytvořena" % grp.name, "success")
            redirect("/groups/edit/%i" % grp.group_id)
        else:
            msg("Chyba při vytváření skupiny", "error")
            redirect(request.path)

    groups = Group.getAll() if usr.inRole("master") else Group.getAll(usr.login)

    return template("groups", {"groups": groups, "showLector": usr.inRole("master")})
Beispiel #21
0
def list():
    """Seznam skupin"""
    
    usr = getUser() 
    
    # vložení nové skupiny
    if request.forms.get("add"):
        grp = Group.insert( request.forms.decode().get("add"), usr.login )
        if grp:
            msg("Skupina %s vytvořena" % grp.name,"success")
            redirect("/groups/edit/%i" % grp.group_id )
        else:
            msg("Chyba při vytváření skupiny","error")
            redirect(request.path)
        
    groups = Group.getAll() if usr.inRole("master") else Group.getAll(usr.login) 
    
    return template("groups", {"groups" : groups, "showLector": usr.inRole("master") } )
Beispiel #22
0
def edit(group_id):
    """Úprava specifické skupiny včetně přidávání uživatelů"""

    user = getUser()
    group = Group.get(group_id)

    if not (user.inRole("master") or group.lector == user.login):
        return unauthorized()

    # vložení studenta
    if request.forms.get("add"):
        try:
            usr = User.insertStudent(request.forms.get("add"), group_id)
            msg("Student %s vložen" % usr.login, "success")
        except Exception as e:
            msg("Chyba při vkládání studenta - %s " % e, "error")

        redirect(request.path)

    # odstranění studenta
    if request.query.get("remove"):
        usr = User.get(request.query.get("remove"))

        if not usr:
            msg("Student nenalezen", "error")
        elif usr.remove():
            msg("Student %s odstraněn" % usr.login, "success")
        else:
            msg("Student nenalezen", "error")

        redirect(request.path)

    form = GroupForm(request.forms.decode(), group)

    if request.method == "POST" and form.validate():
        try:
            group.update(name=form.name.data)
            msg("Skupina aktualizována", "success")
        except Exception as e:
            msg("Chyba při aktualizaci - %s" % e, "error")

        redirect(request.path)

    return template("groups_edit", {"group": group, "form": form_renderer(form)})
Beispiel #23
0
def delete(lecture_id):
    """Smaže cvičení"""

    lecture = Lecture.get( lecture_id )
    user = getUser()

    if not ( user.inRole("master") or lecture.lector == user.login):
        return unauthorized()


    answer = request.forms.get("answer") 
    if answer:
        if answer == "Ne": redirect("/lectures")
        if answer == "Ano":
            lecture.remove()
            msg("Cvičení smazáno","success")
            redirect("/lectures")
            
    return template("question", {"question":"Skutečně chcete smazat cvičení '%s'" % lecture.name } )    
Beispiel #24
0
def delete(group_id):
    """Smaže skupinu"""

    user = getUser()
    group = Group.get(group_id)

    if not (user.inRole("master") or group.lector == user.login):
        return unauthorized()

    answer = request.forms.get("answer")
    if answer:
        if answer == "Ne":
            redirect("/groups")
        if answer == "Ano":
            group.remove()
            msg("Skupina smazána", "success")
            redirect("/groups")

    return template("question", {"question": "Skutečně chcete smazat skupinu '%s'" % group.name})
Beispiel #25
0
def delete(lecture_id):
    """Smaže cvičení"""

    lecture = Lecture.get(lecture_id)
    user = getUser()

    if not (user.inRole("master") or lecture.lector == user.login):
        return unauthorized()

    answer = request.forms.get("answer")
    if answer:
        if answer == "Ne": redirect("/lectures")
        if answer == "Ano":
            lecture.remove()
            msg("Cvičení smazáno", "success")
            redirect("/lectures")

    return template(
        "question",
        {"question": "Skutečně chcete smazat cvičení '%s'" % lecture.name})
def newuser():
    time.sleep(1)
    camera = get_camera()
    stamp = camera.captureforaldreadyuser()

    stamp1 = "static/captures/test.jpg"

    flag, name = check_face_match(stamp, stamp1)

    rv = getUser(name)
    id = 0

    for r in rv:
        name = r[0]
        health = r[1]
        allergies = r[2]
        id = r[3]

    if 'id' in session:
        session['id'] = id
    else:
        session['id'] = id

    if flag == True:
        mac_say.say("Hello" + name)
        time.sleep(1)
        mac_say.say("I have missed seeing you. How are you today?")
        time.sleep(2)
        mac_say.say("I hope you are having a wonderful day.")
        time.sleep(2)
        mac_say.say("Please select one of the following options")
        return render_template("page1.html",
                               name=name,
                               health=health,
                               allergies=allergies)
    else:
        mac_say.say("I see that we are meeting first time")
        time.sleep(2)
        mac_say.say("Please click the button if you like to be my friend?")
        return render_template("newuser.html")
Beispiel #27
0
def show(lecture_id):
    """Zobrazení a odevzdávání zadání """
                  
    usr = getUser()
    lec = Lecture.get( lecture_id );
    
    if not lec: return HTTPError(404, "Cvičení nebylo nalezeno")

    if not lec.isActive():
        msg("Cvičení není aktivní", "error")
        redirect("/assigments");
                      
    assigment = Assigment.getUnique( lecture_id, usr.login ) 
    
    if not assigment:
        assigment = Assigment.create( lec.lecture_id, lec.generate(), usr.login )
        msg("Cvičení bylo vygenerováno", "success")
        
    if request.method == 'POST' and request.files.response:
        try:        
            assigment.respond( request.files.response.file.read() )
            msgTxt = "Řešení bylo úspěšně odesláno";

            if request.is_xhr:
                 return HTTPResponse({"type": "success", "msg": msgTxt});
            msg(msgTxt ,"success")
            
        except Exception as e:
           msgTxt = "Chyba při odesílání řešení - %s" % e 
           
           if request.is_xhr:
                 return HTTPResponse({"type": "error", "msg": msgTxt});
                 
           msg(msgTxt, "error")
        
        redirect(request.path)
            
    return template("assigments_show", {"assigment" : assigment, "lecture": lec } )    
Beispiel #28
0
def download(group_id):
    """Stažení výsledků skupiny ve wis formátu"""
    
    user = getUser()
    group = Group.get( group_id )
    
    if not ( user.inRole("master") or group.lector == user.login):
        return unauthorized()

    headers = {}
    headers['Content-Type'] = "text/csv"
    headers['Content-Disposition'] = 'attachment; filename="%s.csv"' %  slug(group.name)

    #Formát CSV: 1. ID, 2. jméno, 3. login, 4. body, 5. celk.body, 6. datum, 7. login zadávajícího
    #při importu musí být zachováno pořadí sloupců, stačí vyplnit sloupce 3. a 4., případně 6.
    date = today()
    data = []
    results = group.getResults()
    for login, points in results.items():
        data.append(";;%s;%s;;%s;%s;" % (login, points, date, group.lector) );

    data = "\n".join(data)

    return HTTPResponse(data, **headers)
Beispiel #29
0
def download(group_id):
    """Stažení výsledků skupiny ve wis formátu"""

    user = getUser()
    group = Group.get(group_id)

    if not (user.inRole("master") or group.lector == user.login):
        return unauthorized()

    headers = {}
    headers["Content-Type"] = "text/csv"
    headers["Content-Disposition"] = 'attachment; filename="%s.csv"' % slug(group.name)

    # Formát CSV: 1. ID, 2. jméno, 3. login, 4. body, 5. celk.body, 6. datum, 7. login zadávajícího
    # při importu musí být zachováno pořadí sloupců, stačí vyplnit sloupce 3. a 4., případně 6.
    date = today()
    data = []
    results = group.getResults()
    for login, points in results.items():
        data.append(";;%s;%s;;%s;%s;" % (login, points, date, group.lector))

    data = "\n".join(data)

    return HTTPResponse(data, **headers)
Beispiel #30
0
    def get(self):
        #"3:00:00 PM";1104134;"*****@*****.**";"General";" $15,000,000.00
        #";"10%";;;;;"Noncompetitive";;"Auto";"12/15/11 12:53 PM"
        Bid( key_name="3:00:00 PM 1104134",
                bidtype = 'General',
                user = getUser('*****@*****.**'),
                aggregated = 15000000.00,
                status = 'Active',
                participation = 0.10,
                ordertype = "Noncompetitive",
                createdAt = datetime.datetime.strptime("3:00:00 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Auto",
                orderAt = datetime.datetime.strptime("12/15/11 12:53 PM", "%m/%d/%y %I:%M %p")
                ).put()

        #"3:00:00 PM";1104143;"*****@*****.**";"Specified";;;"20%";"MO";;"ABC
        #Mortgage";"Noncompetitive";;"Auto";"12/20/11 8:43 AM"
        Bid( key_name="3:00:00 PM 1104143",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.20,
                lorm = "MO",
                ordertype = "Noncompetitive",
                createdAt = datetime.datetime.strptime("3:00:00 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Auto",
                mo = getUser('*****@*****.**'),
                orderAt = datetime.datetime.strptime("12/20/11 8:43 AM", "%m/%d/%y %I:%M %p")
                ).put()

        #"3:00:00 PM";1104154;"*****@*****.**";"General";" $20,000,000.00
        #";"20%";;;;;"Competitive";"3.000%";"Auto";"1/5/12 9:16 AM"
        Bid( key_name="3:00:00 PM 1104154",
                bidtype = 'General',
                user = getUser('*****@*****.**'),
                aggregated = 20000000.00,
                status = 'Active',
                participation = 0.20,
                ordertype = "Competitive",
                bidrate = 0.03,
                createdAt = datetime.datetime.strptime("3:00:00 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Auto",
                orderAt = datetime.datetime.strptime("1/5/12 9:16 AM", "%m/%d/%y %I:%M %p")
                ).put()

        #"3:00:00
        #PM";1104152;"*****@*****.**";"Specified";;;"20%";"MO";;"Prime
        #Lending";"Competitive";"3.000%";"Auto";"1/5/12 9:15 AM"
        Bid( key_name="3:00:00 PM 1104152",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.20,
                lorm = "MO",
                ordertype = "Competitive",
                bidrate = 0.03,
                createdAt = datetime.datetime.strptime("3:00:00 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                mo = getUser('*****@*****.**'),
                ordertiming = "Auto",
                orderAt = datetime.datetime.strptime("1/5/12 9:15 AM", "%m/%d/%y %I:%M %p")
                ).put()

        #"5:06:12
        #PM";1104136;"*****@*****.**";"Specified";;;"20%";"Loan";4;;"Competitive";"6.000%";"Day
        #Trade";
        Bid( key_name="5:06:12 PM 1104136",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.20,
                lorm = "Loan",
                loan = getLoan("201149669"),
                ordertype = "Competitive",
                bidrate = 0.06,
                createdAt = datetime.datetime.strptime("5:06:12 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"6:32:36 PM";1104138;"*****@*****.**";"General";" $1,000,000.00
        #";"50%";;;;;"Competitive";"2.125%";"Day Trade";
        Bid( key_name="6:32:36 PM 1104138",
                bidtype = 'General',
                user = getUser('*****@*****.**'),
                aggregated = 1000000.00,
                status = 'Active',
                participation = 0.50,
                ordertype = "Competitive",
                bidrate = 0.02125,
                createdAt = datetime.datetime.strptime("6:32:36 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"7:15:48 PM";1104139;"*****@*****.**";"General";" $500,000.00
        #";"30%";;;;;"Competitive";"2.250%";"Day Trade";
        Bid( key_name="7:15:48 PM  1104139",
                bidtype = 'General',
                user = getUser('*****@*****.**'),
                aggregated = 500000.00,
                status = 'Active',
                participation = 0.30,
                ordertype = "Competitive",
                bidrate = 0.02250,
                createdAt = datetime.datetime.strptime("7:15:48 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"7:59:00
        #PM";1104140;"*****@*****.**";"Specified";;;"20%";"Loan";5;;"Competitive";"2.500%";"Day
        #Trade";
        Bid( key_name="7:59:00 PM 1104140",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.20,
                lorm = "Loan",
                loan = getLoan("201148440"),
                ordertype = "Competitive",
                bidrate = 0.0250,
                createdAt = datetime.datetime.strptime("7:59:00 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"8:42:12 PM";1104141;"*****@*****.**";"General";" $500,000.00
        #";"20%";;;;;"Competitive";"2.500%";"Day Trade";
        Bid( key_name="8:42:12 PM 1104141",
                bidtype = 'General',
                user = getUser('*****@*****.**'),
                aggregated = 500000.00,
                status = 'Active',
                participation = 0.20,
                ordertype = "Competitive",
                bidrate = 0.0250,
                createdAt = datetime.datetime.strptime("8:42:12 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"9:39:48
        #PM";1104159;"*****@*****.**";"Specified";;;"20%";"Loan";1;;"Noncompetitive";;"Day
        #Trade";
        Bid( key_name="9:39:48 PM 1104159",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.0200,
                lorm = "Loan",
                loan = getLoan("201148329"),
                ordertype = "Noncompetitive",
                createdAt = datetime.datetime.strptime("9:39:48 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"11:06:12
        #PM";1104161;"*****@*****.**";"Specified";;;"20%";"Loan";4;;"Noncompetitive";;"Day
        #Trade";
        Bid( key_name="11:06:12 PM 1104161",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.20,
                lorm = "Loan",
                loan = getLoan("201149669"),
                ordertype = "Noncompetitive",
                createdAt = datetime.datetime.strptime("11:06:12 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"11:35:00
        #PM";1104145;"*****@*****.**";"Specified";;;"10%";"Loan";1;;"Competitive";"1.500%";"Day
        #Trade";
        Bid( key_name="11:35:00 PM 1104145",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.10,
                lorm = "Loan",
                loan = getLoan("201148329"),
                ordertype = "Competitive",
                bidrate = 0.0150,
                createdAt = datetime.datetime.strptime("11:35:00 PM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"2:23:00
        #AM";1104133;"*****@*****.**";"Specified";;;"20%";"Loan";4;;"Competitive";"4.000%";"Day
        #Trade";
        Bid( key_name="2:23:00 AM 1104133",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.200,
                lorm = "Loan",
                loan = getLoan("201149669"),
                ordertype = "Competitive",
                bidrate = 0.040,
                createdAt = datetime.datetime.strptime("2:23:00 AM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"2:27:48
        #AM";1104149;"*****@*****.**";"Specified";;;"20%";"Loan";5;;"Noncompetitive";;"Day
        #Trade";
        Bid( key_name="2:27:48 AM 1104149",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.200,
                lorm = "Loan",
                loan = getLoan("201148440"),
                ordertype = "Noncompetitive",
                createdAt = datetime.datetime.strptime("2:27:48 AM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"3:54:12
        #AM";1104151;"*****@*****.**";"Specified";;;"20%";"Loan";1;;"Noncompetitive";;"Day
        #Trade";
        Bid( key_name="3:54:12 AM 1104151",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.200,
                lorm = "Loan",
                loan = getLoan("201148329"),
                ordertype = "Noncompetitive",
                createdAt = datetime.datetime.strptime("3:54:12 AM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"4:37:24 AM";1104131;"*****@*****.**";"General";" $1,000,000.00
        #";"50%";;;;;"Noncompetitive";;"Day Trade";
        Bid( key_name="4:37:24 AM 1104131",
                bidtype = 'General',
                user = getUser('*****@*****.**'),
                aggregated = 1000000.00,
                status = 'Active',
                participation = 0.500,
                ordertype = "Noncompetitive",
                createdAt = datetime.datetime.strptime("4:37:24 AM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"6:47:00 AM";1104155;"*****@*****.**";"Specified";;;"20%";"MO";;"Best
        #Loans Inc";"Competitive";"2.125%";"Day Trade";
        Bid( key_name="6:47:00 AM 1104155",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.20,
                lorm = "MO",
                ordertype = "Competitive",
                bidrate = 0.02125,
                createdAt = datetime.datetime.strptime("6:47:00 AM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                mo = getUser('*****@*****.**'),
                ordertiming = "Day Trade"
                ).put()

        #"7:30:12
        #AM";1104156;"*****@*****.**";"Specified";;;"20%";"Loan";2;;"Noncompetitive";;"Day
        #Trade";
        Bid( key_name="7:30:12 AM 1104156",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.200,
                lorm = "Loan",
                loan = getLoan("201148009"),
                ordertype = "Noncompetitive",
                createdAt = datetime.datetime.strptime("7:30:12 AM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"8:13:24 AM";1104157;"*****@*****.**";"General";" $1,000,000.00
        #";"30%";;;;;"Noncompetitive";;"Day Trade";
        Bid( key_name="8:13:24 AM 1104157",
                bidtype = 'General',
                user = getUser('*****@*****.**'),
                aggregated = 1000000.00,
                status = 'Active',
                participation = 0.30,
                ordertype = "Noncompetitive",
                createdAt = datetime.datetime.strptime("8:13:24 AM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()

        #"8:56:36
        #AM";1104158;"*****@*****.**";"Specified";;;"20%";"Loan";1;;"Competitive";"2.250%";"Day
        #Trade";
        Bid( key_name="8:56:36 AM 1104158",
                bidtype = 'Specified',
                user = getUser('*****@*****.**'),
                status = 'Active',
                participation = 0.20,
                lorm = "Loan",
                loan = getLoan("201148329"),
                ordertype = "Competitive",
                bidrate = 0.02250,
                createdAt = datetime.datetime.strptime("8:56:36 AM", "%I:%M:%S %p"),
                expiresAt = datetime.datetime.strptime("12/15/13 12:53 PM", "%m/%d/%y %I:%M %p"),
                ordertiming = "Day Trade"
                ).put()
def index():
    usr = getUser()
    if usr and usr.inRole("student"):
        redirect("/assigments")
    return template("index")
Beispiel #32
0
import requests
import json
from lxml import etree
import time
import datetime
import random
import user
from selenium import webdriver


userInfo = user.getUser()

def makePick(matchup, selection):
    try:
        driver = webdriver.Chrome()
        driver.get('http://espn.com/login')
        time.sleep(2)
        # C:\Users\robsmith\AppData\Local\Microsoft\WindowsApps
        driver.switch_to.frame(driver.find_element_by_id("disneyid-iframe"))
#        driver.switch_to.frame(driver.find_element_by_tag_name("iframe"))
#        driver.switch_to.frame(driver.find_element_by_name("disneyid-iframe"))
        driver.find_element_by_xpath("//input[@type='email']").send_keys(userInfo['data']['loginValue']);
        driver.find_element_by_xpath("//input[@type='password']").send_keys(userInfo['data']['password']);
        driver.find_element_by_xpath("//button[@type='submit']").click();
        time.sleep(2)
        driver.get('http://fantasy.espn.com/streak/en/createOrUpdateEntry?matchup=m' + matchup + 'o' + selection)
        time.sleep(2)
        driver.close()
        
    except ConnectionError:
        print("connectionerror")
Beispiel #33
0
def index():
    usr = getUser()
    if usr and usr.inRole("student"):
        redirect("/assigments")
    return template("index")
Beispiel #34
0
def groupMenu():
    usr = getUser() 

    if usr and usr.inRole("lector"):
        addMenu("/groups","Skupiny",50)
Beispiel #35
0
def groupMenu():
    usr = getUser()

    if usr and usr.inRole("lector"):
        addMenu("/groups", "Skupiny", 50)
Beispiel #36
0
def groupMenu():
    usr = getUser()

    if usr and usr.inRole("lector"):
        addMenu("/templates", "Šablony", 90)
Beispiel #37
0
def apiIsStale(phoneNumber,url):
    user = getUser(hashVal(phoneNumber))
    if not user :
        return jsonify({"msg" : "failed"})
    return jsonify({"msg" : str(user.isStale(url))})
Beispiel #38
0
def apiUpdatePass(phoneNumber,url,code):
    user = getUser(hashVal(phoneNumber))
    if not user or not user.checkCode(int(code)):
        return jsonify({"msg" : "failed"})
    user.updateSalt(url)
    return jsonify({"msg" : "success"})
Beispiel #39
0
def apiGenNewPass(phoneNumber, code, url):
    user = getUser(hashVal(phoneNumber))
    if not user or not user.checkCode(int(code)):
        return jsonify({"msg" : "failed"})
    return jsonify({"msg" : user.genPass(url,False)})
Beispiel #40
0
import user

user = User('werwe', '2343')
user.getUser()
Beispiel #41
0
def lectureMenu():
    usr = getUser() 

    if usr and usr.inRole("lector"):
        addMenu("/lectures","Cvičení",25)
Beispiel #42
0
def lectureMenu():
    usr = getUser()

    if usr and usr.inRole("lector"):
        addMenu("/lectures", "Cvičení", 25)