示例#1
0
def modify_honor():
    if not current_user.is_admin and not current_user.is_coach:
        return redirect(url_for('main.index'))
    honor_form = form.HonorForm()
    honor_form.users.choices = user_server.get_user_choice()
    try:
        honor = honor_server.get_by_id(request.args['p'])
    except:
        return redirect(url_for('admin.manage_honor'))
    honor_form.id.data = honor.id
    honor_form.introduce.data = honor.introduce
    honor_form.acquire_time.data = honor.acquire_time
    honor_form.contest_name.data = honor.contest_name
    honor_form.team_name.data = honor.team_name
    honor_form.contest_level.data = str(honor.contest_level)
    users = []
    for user in honor.users:
        users.append(user.username)
    honor_form.users.data = users
    upload_form = form.FileUploadForm()
    from dao.dbResource import ResourceLevel, ResourceUsage
    upload_form.level.data = str(ResourceLevel.PUBLIC)
    upload_form.usage.data = str(ResourceUsage.HONOR_RES)
    return render_template('edit_honor.html',
                           title=u'修改荣誉',
                           honor_form=honor_form,
                           upload_form=upload_form,
                           show_upload=False)
示例#2
0
def edit_news():
    if not current_user.is_admin and not current_user.is_coach:
        return redirect(url_for('main.index'))
    try:
        one = news_server.get_by_id(request.args['p'])
    except:
        return redirect(url_for('admin.manage_news'))
    news_form = form.NewsForm()
    upload_form = form.FileUploadForm()
    from dao.dbResource import ResourceLevel, ResourceUsage
    upload_form.level.data = str(ResourceLevel.PUBLIC)
    upload_form.usage.data = str(ResourceUsage.NEWS_RES)
    if one:
        news_form.sid.data = one.id
        news_form.title.data = one.title
        news_form.content.data = one.shortcut + '<-more->' + one.content
        news_form.url.data = one.url
        news_form.is_top.data = one.is_top
        tags = []
        for tag in one.tags:
            tags.append(tag.__repr__())
        news_form.tags.data = tags
    if one.is_draft:
        my_button = [u"保存草稿", u"直接发布"]
    else:
        my_button = [u"保存草稿", u"提交更新"]
    return render_template('post_news.html',
                           title=u'修改新闻',
                           action=u'修改新闻',
                           news_form=news_form,
                           upload_form=upload_form,
                           my_button=my_button)
示例#3
0
def manage_resource():
    file_upload_form = form.FileUploadForm()
    if not current_user.is_admin and not current_user.is_coach:
        file_upload_form.usage.choices = [('3',u'题解资源'), ('4',u'其他资源')]
    return render_template('manage_resource.html',
                           title = u'资源管理',
                           user = current_user,
                           limit = config.RESOURCE_MANAGE_PER_PAGE,
                           upload_form = file_upload_form)
示例#4
0
def add_honor():
    if not current_user.is_admin and not current_user.is_coach:
        return redirect(url_for('main.index'))
    honor_form = form.HonorForm()
    honor_form.users.choices = user_server.get_user_choice()
    upload_form = form.FileUploadForm()
    from dao.dbResource import ResourceLevel, ResourceUsage
    upload_form.level.data = str(ResourceLevel.PUBLIC)
    upload_form.usage.data = str(ResourceUsage.HONOR_RES)
    return render_template('add_honor.html',
                           title=u'添加荣誉',
                           honor_form=honor_form,
                           upload_form=upload_form,
                           show_upload=True)
示例#5
0
def post_news():
    if not current_user.is_admin and not current_user.is_coach:
        return redirect(url_for('main.index'))
    news_form = form.NewsForm()
    upload_form = form.FileUploadForm()
    from dao.dbResource import ResourceLevel, ResourceUsage
    upload_form.level.data = str(ResourceLevel.PUBLIC)
    upload_form.usage.data = str(ResourceUsage.NEWS_RES)
    my_button = [u"保存草稿", u"直接发布"]
    return render_template('post_news.html',
                           title=u'发布新闻',
                           action=u'发布新闻',
                           news_form=news_form,
                           upload_form=upload_form,
                           my_button=my_button)