Beispiel #1
0
def guest_delete(ID):
    if AUTHORITY_TEST("ADMIN") == False:
        return render_template("INVALID_AUTHORITY.html",
                               a1=current_user.authority,
                               a2="ADMIN")
    g = model.Guest()
    g.Delete(ID)
    return redirect(url_for("index"))
Beispiel #2
0
def register():

    form = Register_Form()

    if form.validate_on_submit():
        guest = model.Guest(form)
        if guest.valid() == True:
            guest.save_file()
            flash("Your request has been sent.")
            return redirect(url_for("index"))
    form.Email.data = ""
    return render_template("register.html", form=form)
Beispiel #3
0
def guest_add(ID):
    if AUTHORITY_TEST("ADMIN") == False:
        return render_template("INVALID_AUTHORITY.html",
                               a1=current_user.authority,
                               a2="ADMIN")
    g = model.Guest()
    if g.init_file(ID):
        if g.save_all():
            g.Delete(ID)
            flash("Success! id = %s" % ID)
        else:
            flash("fail in save data!")
    else:
        flash("fail in init the guest!")
    return redirect(url_for("index"))
Beispiel #4
0
def index():
    print(current_user.authority)
    print(current_user.id)
    sc = model.Student_Course()
    if current_user.authority == "STAFF" or current_user.authority == "STUDENT" or current_user.authority == "GUEST":
        sp = model.Surveys_Pool()
        sl = sp.Show()
        cl = []
        for s in sl:
            rv = sc.Get(current_user.id, s.Course_Semester)
            if rv == 1 and current_user.authority != "ADMIN":
                continue
            if s.Course_Semester not in cl:
                cl.append(s.Course_Semester)

        cl.sort()
        scl = sc.Show()
        cl2 = []
        for x in scl:
            if x[1] == int(current_user.id):
                cl2.append(x[0])
        cl2.sort()
        for x in cl2:
            if x not in cl:
                cl.append(x)

        if current_user.authority == "STUDENT" or current_user.authority == "GUEST":
            return render_template("student_index.html",
                                   ID=current_user.id,
                                   surveys=sl,
                                   cl=cl)
        else:
            return render_template("staff_index.html",
                                   ID=current_user.id,
                                   surveys=sl,
                                   cl=cl)
    g = model.Guest()
    gl = g.Show()
    return render_template('index.html', guest_list=gl)
Beispiel #5
0
####################
engine  = create_engine(args.db_url)
Session = sessionmaker(bind=engine)

session = Session()

model.Base.metadata.create_all(engine)
model.session=session

# drop everything for reset

session.query(model.Guest).delete(synchronize_session='fetch')
session.query(model.Group).delete(synchronize_session='fetch')

# create a bunch of groups
for n in range(args.groups):
    group=model.Group()
    session.add(group)

session.commit()

# create a bunch of guests    
for n in range(args.guests):
    guest=model.Guest(tolerance=random.uniform(args.min_tolerance, args.max_tolerance))
    session.add(guest)

session.commit()

for g in session.query(model.Guest).all():
    g.update_happiness()