Esempio n. 1
0
def signup():
	off="y"
	signup_on="y"
	# take form filed of JoinForm
	form = JoinForm()
	# check for request method POST
	if request.method=='GET':
		return render_template("signup.html",form=form,signup_on=signup_on,off=off)
	# check for validate
	if not form.validate_on_submit():
		return redirect(url_for("signup"))
	
	# +: check for user email does not include for class User
	inputs=form.email.data
	if User.query.get(inputs):
		alert="danger"
		return render_template("signup.html",form=form,alert=alert,signup_on=signup_on,off=off)

	# commit class User to user data
	user_db=User(
		id=form.email.data,
		password=generate_password_hash(form.password.data)
		)

	db.session.add(user_db)
	db.session.commit()

	return redirect(url_for('index'))
Esempio n. 2
0
def dele():
      form = JoinForm()
      role_list=[]
      zu = Group.query.filter_by(groupname=form.name.data).first()
      if form.validate_on_submit():
          if zu is not None:
                 ren_list=zu.user.all()
                 if g.user in ren_list:
                    for rens in ren_list:
                        role_list.append(rens.role[0])
                    role_list.remove(g.user.role[0])
                    g.user.group.remove(zu)
                    db.session.add(g.user)
                    db.session.commit()
                    flash(u'你已从该群移出!')      
                 else:
                    flash(u'操作无效,你不是该群成员!')
                    return redirect(url_for('dele'))
          else:
            flash(u'请正确输入群名!')
            return redirect(url_for('dele')) 
      return render_template('delete.html',
                           title='Home',
                           form=form,
                           zu=zu)
Esempio n. 3
0
def signup():
    off = "y"
    signup_on = "y"
    # take form filed of JoinForm
    form = JoinForm()
    # check for request method POST
    if request.method == 'GET':
        return render_template("signup.html",
                               form=form,
                               signup_on=signup_on,
                               off=off)
    # check for validate
    if not form.validate_on_submit():
        return redirect(url_for("signup"))

    # +: check for user email does not include for class User
    inputs = form.email.data
    if User.query.get(inputs):
        alert = "danger"
        return render_template("signup.html",
                               form=form,
                               alert=alert,
                               signup_on=signup_on,
                               off=off)

    # commit class User to user data
    user_db = User(id=form.email.data,
                   password=generate_password_hash(form.password.data))

    db.session.add(user_db)
    db.session.commit()

    return redirect(url_for('index'))
Esempio n. 4
0
def join_group():
    form = JoinForm()
    if form.validate_on_submit():
        cur = mysql.connection.cursor()

        cur.callproc("JOINGROUP", [
            session['username'],
            form.group_id.data,
            datetime.now(),
        ])
        mysql.connection.commit()
        cur.close()
        flash(f' You have sucessfully joined {form.group_id.data}', 'success')
        return redirect(url_for('join_group'))
    cur = mysql.connection.cursor()
    cur.callproc("GETGROUP_INFO", [session['username']])
    join_groups = cur.fetchall()
    cur.close()
    len_group = len(join_groups)
    print("groups:  ", join_groups, len_group)
    return render_template('join_group.html',
                           title='Join a Group',
                           form=form,
                           legend='Join An Existing Group',
                           len_group=len_group,
                           groups=join_groups)
Esempio n. 5
0
def join(): 
    form = JoinForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            # get form data
            username = form.username.data
            learner_name = form.learner_name.data
            email = form.email.data
            hashed_password = generate_password_hash(form.password.data)
            # add form data to database
            info = {
                "username": username,
                "password": hashed_password,
                "email": email,
                "learner_name": learner_name,
                'added': datetime.utcnow(),
            }
            db.users.insert_one(info)
            # add info to session
            session["email"] = email
            session["username"] = username
            session["learner_name"] = learner_name
            # log
            app.logger.info('%s joined successfully', username)
            # flash message
            flash('You have successfully registered and logged in')
            return redirect('/dashboard')
        else:
            # add what happens if it doesn't validate
            for item in form.errors.items():
                app.logger.error("item")
    return render_template('join.html', form=form)
Esempio n. 6
0
def addgroup(tuple):
    display_info = []
    info = tuple.split(",")
    searching = info[0]
    adding = info[2]
    time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

    form = JoinForm()
    group = Group()
    group_info = group.search_group(searching)
    request_1 = Relation_control()

    if group_info is not []:
        for row in group_info:
            request_1.check_request(current_user.user_email, row["name"])

    request_info = request_1.show_request(current_user.user_email)

    for item in group_info:
        for item2 in request_info:
            if item2["name"] == item["name"]:
                display_info.append(item2)

    if form.validate_on_submit():
        search_result = request.form.get('searching', None)
        tuple = search_result + "," + adding + "," + adding
        return redirect(
            request.args.get('next') or url_for('addgroup', tuple=tuple))

    if adding == "!@#$%":
        print("ignore")
    else:
        new_request = request_1.update_request(current_user.user_email, adding,
                                               time)

        i = 0
        for item in display_info:
            if item["name"] == new_request["name"]:
                display_info[i] = new_request
                break
            else:
                i = i + 1

    tuple = searching + "," + adding
    return render_template('addgroup.html',
                           groups=display_info,
                           form=form,
                           tuple=tuple,
                           dada=searching,
                           user_info_global=user_info_global)
Esempio n. 7
0
def join():
    server_error = None
    form = JoinForm()
    if form.validate_on_submit():
        planning_name = request.form['planning']
        password = request.form['password']
        username = request.form['name']

        planning = db.Planning.get(title=planning_name)
        if planning.password != password:
            server_error = "Password is incorrect for the selected planning meeting."
        else:
            stories = []
            for story in planning.stories:
                story_id = story.id
                name = story.name
                response = requests.get(app.config['JIRA']['base_url'] +
                                        app.config['JIRA']['rest_issue'] +
                                        str(name) +
                                        "?fields=description,summary",
                                        auth=(app.config['JIRA']['user'],
                                              app.config['JIRA']['password']))
                data = response.json()
                description = data["fields"]["description"]
                summary = data["fields"]["summary"]
                # TODO move this to the creation phase and add to database
                stories.append({
                    'id': story_id,
                    'name': name,
                    "description": description,
                    "summary": summary
                })

            return render_template('estimate_main.html',
                                   planning_title=planning_name,
                                   stories=stories,
                                   username=username)
    planning_list = select(p.title for p in db.Planning)
    return render_template('estimate_start.html',
                           planning_list=planning_list,
                           error=server_error,
                           form=form)
Esempio n. 8
0
def setup_account(key, token):
    """

    :param key:
    :param token:
    :return:
    """
    form = JoinForm()

    membership = utils.organization.membership_from_key_token(key, token)
    if membership is None:
        flash('Invalid or expired confirmation link', 'danger')
        return redirect(url_for('main.home'))

    if form.validate_on_submit():
        utils.organization.confirm_user(membership.member, form.password.data)
        utils.organization.confirm_invite(membership)
        return redirect(url_for('main.home'))
    else:
        return render_template('main/setup.html', form=form, organization=membership.organization)
Esempio n. 9
0
def join():
    if session.get('logged_in'):
        return redirect(url_for('index'))
    form = JoinForm()
    if form.validate_on_submit():
        try:
            with pg_db.atomic():
                user = User.create(
                    username=form.username.data,
                    password=md5((form.password.data).encode('utf-8')).hexdigest(),
                    email=form.email.data,
                    about_me='',
                    join_date=datetime.now())

            auth_user(user)
            return redirect(url_for('index'))

        except IntegrityError:
            flash('That username or email is already in use')

    return render_template('join.html', form=form, title='Join Us')
Esempio n. 10
0
def showgroups(deletegroup):
    # deletegroup
    group = Group()
    if deletegroup == "None":
        print("haha")
    else:
        group.delete_quit_group(current_user.user_email, deletegroup)
        print("haha222")
    info = group.show_group_join(current_user.user_email)
    print(info)
    form = JoinForm()
    if form.validate_on_submit():
        search_result = request.form.get('searching', None)
        search_result = search_result + ",1,!@#$%"
        return redirect(
            request.args.get('next')
            or url_for('addgroup', tuple=search_result))
    return render_template('showgroups.html',
                           groups=info,
                           form=form,
                           user_info_global=user_info_global)
Esempio n. 11
0
def join():
    form = JoinForm()
    if form.validate_on_submit():
        s = Group.query.filter_by(groupname=form.name.data).first()
        user_role=g.user.role.all()
        if s is None:
            flash(u'此群未建立')
        else:
            ren_list=s.user.all()
            for ren in ren_list:
                if ren==g.user:
                    flash(u'你在该组群,不需重新加入!')
                    return redirect(url_for('join'))
            else:
                if user_role==[]:
                    flash(u'请先编辑你的信息,再加入群组!')
                    return redirect(url_for('join'))
                else:
                    g.user.group.append(s)
                    db.session.add(g.user)
                    db.session.commit()
                    flash(u'加入成功!')					      
    return render_template('join.html', form=form)
Esempio n. 12
0
File: iot.py Progetto: rlunding/iot
def join():
    """Join

    Join the chord-network which the node with the provided ip and port is part of.

    :param ip: the ip-address of the node which should be joined.
    :param port: the port of the node which should be joined.
    :returns: html page with node information, possible also with errors if the input is invalid.
    """
    join_form = JoinForm()
    if join_form.validate_on_submit():
        join_ip = request.form.get('ip')
        join_port = request.form.get('port')
        node.join(join_ip, join_port)
        flash('Successfully join network', 'success')
        return redirect(url_for('home'))
    search_form = SearchForm()
    add_form = AddForm()
    return render_template('home.html',
                           node=node,
                           join_form=join_form,
                           add_form=add_form,
                           search_form=search_form)