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


Python DataManager.add_attendee_role_to_event方法代码示例

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


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

示例1: initiate_order_payment

# 需要导入模块: from app.helpers.data import DataManager [as 别名]
# 或者: from app.helpers.data.DataManager import add_attendee_role_to_event [as 别名]
    def initiate_order_payment(form):
        identifier = form['identifier']
        email = form['email']

        order = TicketingManager.get_and_set_expiry(identifier)

        if order:

            user = TicketingManager.get_or_create_user_by_email(email, form)
            order.user_id = user.id

            if order.amount > 0 \
                and (not order.paid_via
                     or (order.paid_via
                         and (order.paid_via == 'stripe'
                              or order.paid_via == 'paypal'))):

                country = form['country']
                address = form['address']
                city = form['city']
                state = form['state']
                zipcode = form['zipcode']
                order.address = address
                order.city = city
                order.state = state
                order.country = country
                order.zipcode = zipcode
                order.status = 'initialized'
            else:
                order.status = 'completed'
                order.completed_at = datetime.utcnow()
                if not order.paid_via:
                    order.paid_via = 'free'

            holders_firstnames = form.getlist('holders[firstname]')
            holders_lastnames = form.getlist('holders[lastname]')
            holders_ticket_ids = form.getlist('holders[ticket_id]')
            holders_emails = form.getlist('holders[email]')

            for i, firstname in enumerate(holders_firstnames):
                data = {
                    'firstname': firstname,
                    'lastname': holders_lastnames[i]
                }
                holder_user = TicketingManager.get_or_create_user_by_email(holders_emails[i], data)
                ticket_holder = TicketHolder(firstname=data['firstname'],
                                             lastname=data['lastname'],
                                             ticket_id=int(holders_ticket_ids[i]),
                                             email=holder_user.email, order_id=order.id)
                DataManager.add_attendee_role_to_event(holder_user, order.event_id)
                db.session.add(ticket_holder)

            # add attendee role to user
            DataManager.add_attendee_role_to_event(user, order.event_id)
            # save items
            save_to_db(order)
            return order
        else:
            return False
开发者ID:ashishpahwa7,项目名称:open-event-orga-server,代码行数:61,代码来源:ticketing.py

示例2: initiate_order_payment

# 需要导入模块: from app.helpers.data import DataManager [as 别名]
# 或者: from app.helpers.data.DataManager import add_attendee_role_to_event [as 别名]
    def initiate_order_payment(form, paid_via=None):
        identifier = form['identifier']
        email = form['email']

        order = TicketingManager.get_and_set_expiry(identifier)

        if order:
            user = DataGetter.get_or_create_user_by_email(email, form)
            order.user_id = user.id

            if order.amount > 0 \
                and (not order.paid_via
                     or (order.paid_via
                         and (order.paid_via == 'stripe'
                              or order.paid_via == 'paypal'))):

                if paid_via:
                    order.paid_via = paid_via

                country = form['country']
                address = form['address']
                city = form['city']
                state = form['state']
                zipcode = form['zipcode']
                order.address = address
                order.city = city
                order.state = state
                order.country = country
                order.zipcode = zipcode

                if paid_via == 'transfer' or paid_via == 'onsite' or paid_via == 'cheque':
                    order.status = 'placed'
                else:
                    order.status = 'initialized'

            else:
                order.status = 'completed'
                order.completed_at = datetime.utcnow()
                if not order.paid_via:
                    order.paid_via = 'free'

            invoice_id = order.get_invoice_number()
            order_url = url_for('ticketing.view_order_after_payment',
                                order_identifier=order.identifier,
                                _external=True)

            # add holders to user
            holders_firstnames = form.getlist('holders[firstname]')
            holders_lastnames = form.getlist('holders[lastname]')
            holders_ticket_ids = form.getlist('holders[ticket_id]')
            holders_emails = form.getlist('holders[email]')

            for i, firstname in enumerate(holders_firstnames):
                data = {
                    'firstname': firstname,
                    'lastname': holders_lastnames[i]
                }
                holder_user = DataGetter.get_or_create_user_by_email(holders_emails[i], data)
                ticket_holder = TicketHolder(firstname=data['firstname'],
                                             lastname=data['lastname'],
                                             ticket_id=int(holders_ticket_ids[i]),
                                             email=holder_user.email,
                                             order_id=order.id)
                if order.status == "completed":
                    send_email_for_after_purchase(holder_user.email, invoice_id, order_url, order.event.name,
                                                  order.event.organizer_name)
                DataManager.add_attendee_role_to_event(holder_user, order.event_id)
                db.session.add(ticket_holder)

            # add attendee role to user
            if order.status == "completed":
                trigger_after_purchase_notifications(email, order.event_id, order.event, invoice_id, order_url)
                send_email_for_after_purchase(email, invoice_id, order_url, order.event.name,
                                              order.event.organizer_name)
            DataManager.add_attendee_role_to_event(user, order.event_id)
            # save items
            save_to_db(order)
            return order
        else:
            return False
开发者ID:codebhendi,项目名称:open-event-orga-server,代码行数:82,代码来源:ticketing.py


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