コード例 #1
0
def showItems(collection_id):
    collection = session.query(Collection).filter_by(id=collection_id).one()
    creator = getUserInfo(collection.user_id)
    items = session.query(CollectionItem).filter_by(
        collection_id=collection_id).all()
    if 'username' not in login_session or creator.id != login_session['user_id']:
        return render_template('publicitems.html', items=items, collection=collection, creator=creator)
    else:
        return render_template('items.html', items=items, collection=collection, creator=creator)
コード例 #2
0
def showProject(project, projectcategory, project_no):
    list_of_single_project = db_helper.single_project(project_no)
    creator = db_helper.getUserInfo(list_of_single_project.author_id)
    author_name = db_helper.getUserName(list_of_single_project.author_id)

    list_of_comments = db_helper.comments_list(project_no)

    # Handle the POST request
    if request.method == 'POST':
        if 'username' not in login_session:
            return redirect('/login')
        else:
            newComment = db_helper.new_comments(request.form['comments'],
                                                login_session['user_id'],
                                                project_no)
            return render_template('single_project.html',
                                   project=project,
                                   projectcategory=projectcategory,
                                   project_no=project_no,
                                   project_list=list_of_single_project,
                                   author_name=author_name,
                                   project_comments=list_of_comments)

    if 'username' not in login_session or creator.id != login_session[
            'user_id']:
        return render_template('public_single_project.html',
                               project=project,
                               projectcategory=projectcategory,
                               project_no=project_no,
                               project_list=list_of_single_project,
                               author_name=author_name,
                               project_comments=list_of_comments)
    else:
        return render_template('single_project.html',
                               project=project,
                               projectcategory=projectcategory,
                               project_no=project_no,
                               project_list=list_of_single_project,
                               author_name=author_name,
                               project_comments=list_of_comments)
コード例 #3
0
def showProject(project,projectcategory,project_no):
  list_of_single_project = db_helper.single_project(project_no)
  creator = db_helper.getUserInfo(list_of_single_project.author_id)
  author_name = db_helper.getUserName(list_of_single_project.author_id)
     
  list_of_comments = db_helper.comments_list(project_no)  
  
  # Handle the POST request  
  if request.method == 'POST':
    if 'username' not in login_session:
          return redirect('/login')
    else:
      newComment = db_helper.new_comments(request.form['comments'],login_session['user_id'],project_no)
      return render_template('single_project.html', project=project,projectcategory=projectcategory,project_no=project_no,
      project_list=list_of_single_project, author_name=author_name,project_comments = list_of_comments)

  if 'username' not in login_session or creator.id != login_session['user_id']:
    return render_template('public_single_project.html',project=project,projectcategory=projectcategory,project_no=project_no,
      project_list=list_of_single_project, author_name=author_name,project_comments = list_of_comments)
  else:
    return render_template('single_project.html', project=project,projectcategory=projectcategory,project_no=project_no,
      project_list=list_of_single_project, author_name=author_name,project_comments = list_of_comments)