当前位置: 首页>>代码示例>>Python>>正文


Python PageData.trademessage方法代码示例

本文整理汇总了Python中main.PageData.trademessage方法的典型用法代码示例。如果您正苦于以下问题:Python PageData.trademessage方法的具体用法?Python PageData.trademessage怎么用?Python PageData.trademessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在main.PageData的用法示例。


在下文中一共展示了PageData.trademessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: trade

# 需要导入模块: from main import PageData [as 别名]
# 或者: from main.PageData import trademessage [as 别名]
def trade(username, itemid=None, messageid=None):
    pd = PageData()

    status = messagestatus['unread_trade']

    try:
        pd.tradeuser = SiteUser.create(username)
    except NoUser:
        return page_not_found(404)

    if 'username' in session:
        if request.method == 'POST':
            authuseritems = request.form.getlist('authuseritem')
            tradeuseritems = request.form.getlist('tradeuseritem')
            message = request.form['body']
            subject = request.form['subject']

            if 'parent' in request.form:
                parent = request.form['parent']
            else:
                if messageid:
                    parent = core.deobfuscate(messageid)
                    messageid = parent
                    status = messagestatus['unread_pm']
                    flashmsg = 'Message sent!'
                else:
                    parent = None
                    messageid = None
                    flashmsg = 'Submitted trade request!'

            if message and subject:
                pmid = send_pm(pd.authuser.uid, pd.tradeuser.uid, subject, message, status, parent)

                if not messageid:
                    messageid = pmid
                elif tradeuseritems or authuseritems:
                    flashmsg = 'Trade updated'

                for item in authuseritems:
                    add_tradeitem(item, messageid, pd.authuser.uid, tradeitemstatus['accepted'])

                for item in tradeuseritems:
                    add_tradeitem(item, messageid, pd.tradeuser.uid, tradeitemstatus['unmarked'])

                flash(flashmsg)
                return redirect('/user/' + pd.authuser.username + '/pm/' + obfuscate(messageid))

            if message == '':
                flash('Please add a message')

            return redirect_back('/')

    pd.title = "Trading with {}".format(username)

    try:
        pd.authuser.ownwant = pd.authuser.query_collection(itemid)
    except AttributeError:
        pass

    try:
        pd.tradeuser.ownwant = pd.tradeuser.query_collection(itemid)
        pd.item = SiteItem(itemid)
    except NoItem:
        if messageid:
            try:
                pd.trademessage = TradeMessage.create(deobfuscate(messageid))
            except NoItem:
                return page_not_found(404)
        else:
            return page_not_found(404)

    return render_template('trade.html', pd=pd)
开发者ID:oamike,项目名称:scarfage,代码行数:74,代码来源:trade.py


注:本文中的main.PageData.trademessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。