Beispiel #1
0
def confilm():
    '''
    確認ページ
    '''
    if request.method == "GET":
        return render_template('confilm.html', session=session)
    else:
        # name が unique かチェック
        name = session.get('name')
        member_name = MemberContent.query.filter_by(name=name).first()
        if member_name:
            return redirect(url_for('complete', status='user_notunique'))
        # email が unique かチェック
        email = session.get('email')
        member_email = MemberContent.query.filter_by(email=email).first()
        if member_email:
            return redirect(url_for('complete', status='email_notunique'))
        # birthdayの取得
        birthday = datetime.datetime.strptime(session.get('birthday'),
                                              '%Y-%m-%d')
        # DBへ登録
        try:
            content = MemberContent(name, email, birthday)
            db_session.add(content)
            db_session.commit()
            return redirect(url_for('complete', status='success'))
        except Exception as e:
            return redirect(url_for('complete', status='dbcommit_failed'))
Beispiel #2
0
    def create_tags(self, tags, commit=False):
        if not tags:
            return self

        tags = [tag.lower() for tag in tags]
        tags = set(tags)

        # delete old tags
        for tag in self.tags:
            db_session.delete(tag)

        cls = get_remote_side_class(self, 'tags')
        ref_name = get_remote_side(self, 'tags')
        # create new tags
        for t in tags:
            tag = cls()
            tag.name = t
            setattr(tag, ref_name, self.id)
            db_session.add(tag)

        cache.delete_tags(self)

        if commit:
            db_session.commit()
        return self
Beispiel #3
0
def add():
    feature = request.form["feature"]
    details = request.form["details"]
    content = FeatureContent(feature, details, datetime.now())
    db_session.add(content)
    db_session.commit()
    return redirect(url_for("index"))
 def print(self):
     printer.write_string_to_printer(str(self))
     sleep(5)
     #printer.write_string_to_printer(str(self.print_no_fiscal()))
     self.print_date = datetime.now()
     db_session.add(self)
     db_session.commit()
Beispiel #5
0
def req():
    if request.method == "POST":
        teacher_id = request.form["teacher_id"]
        lecture = Lecture(teacher_id, datetime.now())
        db_session.add(lecture)
        db_session.commit()
    return redirect(url_for("mypage"))  
Beispiel #6
0
def add():
    title = request.form["title"]
    body = request.form["body"]
    content = OnegaiContent(title, body, datetime.now())
    db_session.add(content)
    db_session.commit()
    return redirect(url_for("index"))
Beispiel #7
0
def add_post():
    if ("name" in session):
        if (not session["name"] == None):
            app.add_template_global(name="status", f="login")
            if (request.form["title"]) and (request.form["body"]):
                title = request.form["title"]
                body = request.form["body"]
                check_title = db_session.query(BlogContent).filter_by(
                    title=title).first()
                if check_title:
                    message = title + "は既に使われています"
                    return render_template("add_post.html",
                                           message=message,
                                           title=title,
                                           body=body)
                else:
                    post_data = BlogContent(title, body)
                    db_session.add(post_data)
                    db_session.commit()
                    return redirect(url_for("post", title=title))
            else:
                if request.form["title"]:
                    return render_template("add_post.html",
                                           title=request.form["title"])
                if request.form["body"]:
                    return render_template("add_post.html",
                                           body=request.form["body"])
                if (not request.form["title"]) and (not request.form["body"]):
                    return redirect(url_for("add"))
    else:
        return redirect(url_for("login"))
Beispiel #8
0
def index():
    if request.method == 'GET':
        if "user_name" in session:
            name = session["user_name"]
            posts = Post.query.order_by(Post.due, Post.title).all()
            all_user = User.query.order_by(User.user_name).all()
            title_name = 'index'

            return render_template("index.html",
                                   name=name,
                                   posts=posts,
                                   all_user=all_user,
                                   today=date.today(),
                                   title_name=title_name)
        else:
            return redirect(url_for("top", status="logout"))
    else:
        title = request.form.get('title')
        detail = request.form.get('detail')
        due = request.form.get('due')
        due = datetime.strptime(due, '%Y-%m-%d')
        user_name = session['user_name']
        new_post = Post(title=title,
                        detail=detail,
                        due=due,
                        user_name=user_name)
        db_session.add(new_post)
        db_session.commit()
        db_session.close()
        return redirect('/index')
Beispiel #9
0
def add():
    title = request.form["title"]
    body = request.form["body"]
    content = KitsuneContest(title, body, datetime.now())
    db_session.add(content)
    db_session.commit()
    return index()
Beispiel #10
0
def add():
    title = request.form['title']
    content = PostIt(title, datetime.now())
    print(f'{title}のPOSTを確認')
    db_session.add(content)
    db_session.commit()
    return index()
Beispiel #11
0
def new_user():
    return_data = {'errors': [], 'message': [], 'data': {}}
    try:
        data = request.get_json(force=True)
    except Exception as e:
        return_data['errors'].append(
            'There was a problem with the request. Please try again')
        return_data['errors'].append(e.args)
        return jsonify(return_data)

    validate_user_form(data, return_data)

    #check to see if validation returned any errors
    if return_data['errors']:
        print('there were errors')
        return jsonify(return_data)

    # if no errors go ahead and create the user
    user = User(first_name=return_data['data']['first_name'],
                last_name=return_data['data']['last_name'],
                phone=return_data['data']['phone'],
                email=return_data['data']['email'])

    db_session.add(user)
    db_session.commit()

    return jsonify({'message': 'this worked'})
Beispiel #12
0
def add():
    name = request.form['name']
    type = request.form['type']
    content = CourtInfo(name, type, datetime.now())
    db_session.add(content)
    db_session.commit()
    return redirect(url_for('index'))
Beispiel #13
0
def reset():
    selected_osechi = OsechiWishes.query.filter(OsechiWishes.want != 0).all()
    for i in selected_osechi:
        i.want = 0
        db_session.add(i)
    db_session.commit()
    return start()
Beispiel #14
0
def add():
    title = request.form["title"]
    body = request.form["body"]
    content = YarukotoList(title, body)
    db_session.add(content)
    db_session.commit()
    return redirect(url_for("index"))
Beispiel #15
0
def add():
    title = request.form['title']
    body = request.form['body']
    content = WishContent(title, body, datetime.now())
    db_session.add(content)
    db_session.commit()
    return redirect(url_for('index'))
Beispiel #16
0
def add_agenda():
    project_id = int(session["project_id"])
    agenda = request.form["agenda"]
    content = AgendaContent(project_id, agenda, False, datetime.now())
    db_session.add(content)
    db_session.commit()

    return redirect(url_for("agenda", project_id=project_id))
Beispiel #17
0
def post():
    answer = request.form["answer"]
    id = request.form['id']
    update_status = OsechiWishes.query.filter(OsechiWishes.id == id).first()
    update_status.want = 1 if answer == 'yes' else 2
    db_session.add(update_status)
    db_session.commit()
    return question()
Beispiel #18
0
def post_comments():
    comment = Comments()
    comment.question_id = request.form['question_id']
    comment.content = request.form['content']
    db_session.add(comment)
    db_session.commit()

    return redirect(url_for('question_detail',
                            question_id=comment.question_id))
Beispiel #19
0
 def rate(self, request):
     rating = request.form.get('rate')
     ratingText = request.form.get('text')
     ratingText = None if ratingText == '' else ratingText
     db_session.add(ShopRatings(rating, ratingText))
     db_session.commit()
     self.avg_rating = db_session.query(
         func.avg(ShopRatings.rating).label('average')).first().average
     return jsonify(status='success')
Beispiel #20
0
def add_comment():
    project_id = int(session["project_id"])
    agenda_id = int(session["agenda_id"])
    comment = request.form["comment"]
    content = CommentContent(project_id, agenda_id, comment, datetime.now())
    db_session.add(content)
    db_session.commit()

    return redirect(url_for("comment", agenda_id=agenda_id))
Beispiel #21
0
def review():
    if request.method == "POST":
        teacher_id = request.form["teacher_id"]
        rating = request.form["rating"]
        text = request.form["text"]
        review = Review(teacher_id, rating, text, datetime.now())
        db_session.add(review)
        db_session.commit()
    return redirect(url_for("mypage"))
Beispiel #22
0
def add():
    if "user_name" in session:
        userid = session["user_name"]
        kamoku = request.form["kamoku"]
        kiroku = request.form["kiroku"]
        time = request.form["time"]
        content = studyuser(userid, kamoku, kiroku, time, datetime.now())
        db_session.add(content)
        db_session.commit()
        return redirect(url_for("study"))
Beispiel #23
0
def question_new():
    question_title = request.form["question_title"]
    question_content = request.form["question_content"]
    question = Questions()
    question.title = question_title
    question.content = question_content
    db_session.add(question)
    db_session.commit()

    return redirect(url_for('top'))
Beispiel #24
0
def patch_question(question_id):
    question = Questions.query.filter_by(id=question_id).first()
    question.title = request.form['question_title']
    question.content = request.form['question_content']
    db_session.add(question)
    db_session.commit()

    return jsonify({
        'id': question.id,
        'title': question.title,
        'content': question.content,
    })
Beispiel #25
0
def patch_comments_edit(comment_id):
    comment = db_session.query(Comments).filter(
        Comments.id == comment_id).first()
    comment.content = request.form['content']
    db_session.add(comment)
    db_session.commit()

    return jsonify({
        'id': comment.id,
        'question_id': comment.question_id,
        'content': comment.content,
    })
Beispiel #26
0
def post_sample(sampler_name=None):
    """
    Post matrix to sample
    """
    job_id = func.make_id(sampler_name)
    job = Job(job_id=job_id,
              sampler=sampler_name,
              state=c.waiting,
              date=datetime.datetime.now())
    db_session.add(job)
    db_session.commit()
    return jsonify(dict(job_id=job_id))
Beispiel #27
0
def register():
    userid = request.form['userid']
    username = request.form['username']
    email = request.form['email']
    password = request.form['password']
    if userid is not None and username is not None and password is not None:
        user = Users(userid, username, email, generate_password_hash(password))
        db_session.add(user)
        db_session.commit()
        return render_template('manage/login.html')
    flash("账号密码不能为空", 'error')
    return render_template('manage/register.html')
Beispiel #28
0
def new_garden():
    request_content = request.json
    name = request_content.get('name')
    owner = request_content.get('owner')
    lat = request_content.get('latitude')
    lon = request_content.get('longitude')

    g = Garden(name=name, owner=int(owner), lat=lat, lon=lon)

    db_session.add(g)
    db_session.commit()
    return '', 200
Beispiel #29
0
def register():
    user_name = request.form["user"]
    user = User.query.filter_by(user=user_name).first()
    if user:
        return redirect(url_for("new",status="exist_user"))
    else:
        password = request.form["password"]
        hashed_password = sha256((user_name + password + key.SALT).encode("utf-8")).hexdigest()
        user = User(user_name, hashed_password)
        db_session.add(user)
        db_session.commit()
        session["user_name"] = user_name
        return redirect(url_for("index"))
Beispiel #30
0
def add_data():
    t = " ".join(map(str, request.json['timestamps']))
    k = " ".join(request.json['keys'])
    print(type(request.json["joy_sadness"]))
    print(request.json["keys"])
    c = TapRecord(request.json["error_count"], t, k, request.json["name"], \
        request.json["sentence_length"], request.json["joy_sadness"], \
        request.json["anger_fear"], request.json["trust_disgust"], \
        request.json["interest_distraction"], request.json["impression_pessimism"])
    db_session.add(c)
    db_session.commit()
    print(request.json)
    return "success"
Beispiel #31
0
def add():
    obj = json.loads(request.data, "utf-8")
    for i in obj:
        print obj[i]  # @todo: debug

    table_apk = TableApk()
    table_apk.app_id = obj['appId']
    table_apk.version = obj['version']
    table_apk.version_code = obj['versionCode']
    table_apk.filename = obj['appId'] + '.apk'
    table_app = TableApp(obj)
    table_app.apks = [table_apk]
    db_session.add(table_app)
    db_session.commit()

    app_id = obj["appId"]
    return jsonify(app=dict(id=1, appId=app_id))
Beispiel #32
0
def create_persona():
    p = Persona()
    db_session.add(p)
    db_session.commit()

    return 'POST Persona'
Beispiel #33
0
def update_persona():
    p = Persona()
    db_session.add(p)
    db_dession.commit()

    return "Update persona"