コード例 #1
0
def submit_journal_post_(request):
    form = request.web_input(title="",
                             rating="",
                             friends="",
                             members="",
                             content="",
                             tags="")

    tags = searchtag.parse_tags(form.tags)

    if not define.config_read_bool("allow_submit"):
        raise WeasylError("FeatureDisabled")

    if not define.is_vouched_for(request.userid):
        raise WeasylError("vouchRequired")

    rating = ratings.CODE_MAP.get(define.get_int(form.rating))
    if not rating:
        raise WeasylError("ratingInvalid")

    j = orm.Journal()
    j.title = form.title
    j.rating = rating
    j.content = form.content
    j.submitter_ip_address = request.client_addr
    j.submitter_user_agent_id = get_user_agent_id(ua_string=request.user_agent)
    journalid = journal.create(request.userid,
                               j,
                               friends_only=form.friends,
                               tags=tags)
    raise HTTPSeeOther(location="/journal/%i/%s" %
                       (journalid, slug_for(form.title)))
コード例 #2
0
def submit_visual_post_(request):
    form = request.web_input(submitfile="", thumbfile="", title="", folderid="",
                             subtype="", rating="", friends="", critique="", content="",
                             tags="", imageURL="")

    tags = searchtag.parse_tags(form.tags)

    if not define.config_read_bool("allow_submit"):
        raise WeasylError("FeatureDisabled")

    if not define.is_vouched_for(request.userid):
        raise WeasylError("vouchRequired")

    rating = ratings.CODE_MAP.get(define.get_int(form.rating))
    if not rating:
        raise WeasylError("ratingInvalid")

    s = orm.Submission()
    s.title = form.title
    s.rating = rating
    s.content = form.content
    s.folderid = define.get_int(form.folderid) or None
    s.subtype = define.get_int(form.subtype)
    s.submitter_ip_address = request.client_addr
    s.submitter_user_agent_id = get_user_agent_id(ua_string=request.user_agent)

    submitid = submission.create_visual(
        request.userid, s, friends_only=form.friends, tags=tags,
        imageURL=form.imageURL, thumbfile=form.thumbfile, submitfile=form.submitfile,
        critique=form.critique, create_notifications=('nonotification' not in form))

    if 'customthumb' in form:
        raise HTTPSeeOther(location="/manage/thumbnail?submitid=%i" % (submitid,))
    else:
        raise HTTPSeeOther(location="/submission/%i/%s" % (submitid, slug_for(form.title)))