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


Python data.DataManager类代码示例

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


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

示例1: empty_trash

def empty_trash():
    from app import current_app as app

    with app.app_context():
        events = Event.query.filter(Event.deleted_at.isnot(None)).all()
        users = User.query.filter(User.deleted_at.isnot(None)).all()
        sessions = Session.query.filter(Session.deleted_at.isnot(None)).all()
        pending_orders = Order.query.filter_by(status="pending")

        for event in events:
            if datetime.now() - event.deleted_at >= timedelta(days=30):
                DataManager.delete_event(event.id)

        for user in users:
            if datetime.now() - user.deleted_at >= timedelta(days=30):
                transaction = transaction_class(Event)
                transaction.query.filter_by(user_id=user.id).delete()
                delete_from_db(user, "User deleted permanently")

        for session_ in sessions:
            if datetime.now() - session_.deleted_at >= timedelta(days=30):
                delete_from_db(session_, "Session deleted permanently")

        for pending_order in pending_orders:
            if datetime.now() - pending_order.created_at >= timedelta(days=3):
                pending_order.status = "expired"
                save_to_db(pending_order, "Pending order expired.")
开发者ID:SaptakS,项目名称:open-event-orga-server,代码行数:27,代码来源:scheduled_jobs.py

示例2: create_default_user

def create_default_user():
    print "Your login is 'super_admin'."
    email = raw_input("Enter email for super_admin    : ")
    _validate_email(email)
    password = getpass("Enter password for super_admin : ")
    _validate_password(password)
    DataManager.create_super_admin(email, password)
开发者ID:aviaryan,项目名称:open-event-orga-server,代码行数:7,代码来源:create_db.py

示例3: index_view

    def index_view(self):
        if request.method == 'POST':
            DataManager.update_permissions(request.form)

        perms = dict()
        roles = DataGetter.get_roles()
        services = DataGetter.get_services()
        get_permission = DataGetter.get_permission_by_role_service

        for role in roles:
            perms[role] = dict()
            for service in services:
                perms[role][service.name] = dict()
                p = get_permission(role=role, service=service)
                if not p:
                    perms[role][service.name]['c'] = False
                    perms[role][service.name]['r'] = False
                    perms[role][service.name]['u'] = False
                    perms[role][service.name]['d'] = False
                else:
                    perms[role][service.name]['c'] = p.can_create
                    perms[role][service.name]['r'] = p.can_read
                    perms[role][service.name]['u'] = p.can_update
                    perms[role][service.name]['d'] = p.can_delete

        return self.render(
            '/gentelella/admin/super_admin/permissions/permissions.html',
            perms=sorted(perms.iteritems(),
                         key=lambda (k, v): k.name))
开发者ID:hacktrec,项目名称:open-event-orga-server,代码行数:29,代码来源:permissions.py

示例4: trash_view

def trash_view(event_id):
    if request.method == "GET":
        DataManager.trash_event(event_id)
    flash("Your event has been deleted.", "danger")
    if current_user.is_super_admin:
        return redirect(url_for('sadmin_events.index_view'))
    return redirect(url_for('.index_view'))
开发者ID:codebhendi,项目名称:open-event-orga-server,代码行数:7,代码来源:events.py

示例5: add_session_media

def add_session_media():
    if 'slides' in request.files and request.files['slides'].filename != '':
        url = DataManager.add_session_media(request, 'slides')
        return jsonify({
            'status': 'ok',
            'url': url
        }), 200

    if 'video' in request.files and request.files['video'].filename != '':
        url = DataManager.add_session_media(request, 'video')
        return jsonify({
            'status': 'ok',
            'url': url
        }), 200

    if 'audio' in request.files and request.files['audio'].filename != '':
        url = DataManager.add_session_media(request, 'audio')
        return jsonify({
            'status': 'ok',
            'url': url
        }), 200

    return jsonify({
            'status': 'ok'
        }), 200
开发者ID:codebhendi,项目名称:open-event-orga-server,代码行数:25,代码来源:event_detail.py

示例6: user_role_invite

def user_role_invite(event_id, hash):
    """Accept User-Role invite for the event.
    """
    event = DataGetter.get_event(event_id)
    user = current_user
    role_invite = DataGetter.get_event_role_invite(event.id, hash,
                                                   email=user.email)

    if role_invite:
        if role_invite.has_expired():
            delete_from_db(role_invite, 'Deleted RoleInvite')

            flash('Sorry, the invitation link has expired.', 'error')
            return redirect(url_for('.details_view', event_id=event.id))

        if user.has_role(event.id):
            flash('You have already been assigned a Role in the Event.', 'warning')
            return redirect(url_for('events.details_view', event_id=event_id))

        role = role_invite.role
        data = dict()
        data['user_email'] = role_invite.email
        data['user_role'] = role.name
        DataManager.add_role_to_event(data, event.id)

        # Delete Role Invite after it has been accepted
        delete_from_db(role_invite, 'Deleted RoleInvite')

        flash('You have been added as a %s' % role.title_name)
        return redirect(url_for('.details_view', event_id=event.id))
    else:
        abort(404)
开发者ID:codebhendi,项目名称:open-event-orga-server,代码行数:32,代码来源:events.py

示例7: change_password_view

def change_password_view(hash):
    """Change password view"""
    if request.method == 'GET':
        return render_template('gentelella/users/login/change_password.html')
    if request.method == 'POST':
        DataManager.reset_password(request.form, hash)
        return redirect(url_for('.index'))
开发者ID:SaptakS,项目名称:open-event-orga-server,代码行数:7,代码来源:home.py

示例8: process_event_cfs_speaker

def process_event_cfs_speaker(identifier, via_hash=False):
    if request.method == 'GET':
        event = get_published_event_or_abort(identifier)
        placeholder_images = DataGetter.get_event_default_images()
        if event.sub_topic:
            custom_placeholder = DataGetter.get_custom_placeholder_by_name(event.sub_topic)
        elif event.topic:
            custom_placeholder = DataGetter.get_custom_placeholder_by_name(event.topic)
        else:
            custom_placeholder = DataGetter.get_custom_placeholder_by_name('Other')
        if not event.has_session_speakers:
            abort(404)

        call_for_speakers = DataGetter.get_call_for_papers(event.id).first()

        if not call_for_speakers or (not via_hash and call_for_speakers.privacy == 'private'):
            abort(404)

        form_elems = DataGetter.get_custom_form_elements(event.id)
        speaker_form = json.loads(form_elems.speaker_form)
        session_form = json.loads(form_elems.session_form)

        now = datetime.now(pytz.timezone(event.timezone
                                                  if (event.timezone and event.timezone != '') else 'UTC'))
        start_date = pytz.timezone(event.timezone).localize(call_for_speakers.start_date)
        end_date = pytz.timezone(event.timezone).localize(call_for_speakers.end_date)
        state = "now"
        if end_date < now:
            state = "past"
        elif start_date > now:
            state = "future"
        speakers = DataGetter.get_speakers(event.id).all()
        accepted_sessions_count = get_count(DataGetter.get_sessions(event.id))
        return render_template('gentelella/guest/event/cfs_new_speaker.html',
                               event=event,
                               speaker_form=speaker_form,
                               accepted_sessions_count=accepted_sessions_count,
                               session_form=session_form,
                               call_for_speakers=call_for_speakers,
                               placeholder_images=placeholder_images,
                               state=state,
                               speakers=speakers,
                               via_hash=via_hash,
                               custom_placeholder=custom_placeholder,
                               from_path="cfs")

    if request.method == 'POST':
        email = request.form['email']
        event = DataGetter.get_event_by_identifier(identifier)
        if not event.has_session_speakers:
            abort(404)
        DataManager.add_speaker_to_event(request, event.id)
        if login.current_user.is_authenticated:
            flash("You have been registered as Speaker", "success")
            return redirect(url_for('event_detail.display_event_cfs', identifier=identifier))
        else:
            flash(Markup(
                "You have been registered as Speaker. Please login/register with <strong><u>" + email + "</u></strong> to manage it."),
                "success")
            return redirect(url_for('admin.login_view', next=url_for('my_sessions.display_my_sessions_view')))
开发者ID:rafalkowalski,项目名称:open-event-orga-server,代码行数:60,代码来源:event_detail.py

示例9: process_session_view

def process_session_view(session_id):
    if request.method == 'GET':
        session = DataGetter.get_sessions_of_user_by_id(session_id)
        if not session:
            abort(404)
        form_elems = DataGetter.get_custom_form_elements(session.event_id)
        if not form_elems:
            flash("Speaker and Session forms have been incorrectly configured for this event."
                  " Session creation has been disabled", "danger")
            return redirect(url_for('.display_my_sessions_view', event_id=session.event_id))
        speaker_form = json.loads(form_elems.speaker_form)
        session_form = json.loads(form_elems.session_form)
        event = DataGetter.get_event(session.event_id)
        speaker = DataGetter.get_speakers(session.event_id).filter_by(user_id=login.current_user.id).first()
        return render_template(
            'gentelella/users/mysessions/mysession_detail_edit.html', session=session,
            photo_delete_url=url_for('.avatar_delete', event_id=event.id, speaker_id=speaker.id),
            speaker_form=speaker_form, session_form=session_form, event=event, speaker=speaker)

    if request.method == 'POST':
        session = DataGetter.get_sessions_of_user_by_id(session_id)
        speaker = DataGetter.get_speakers(session.event_id).filter_by(user_id=login.current_user.id).first()
        DataManager.edit_session(request, session, speaker)
        flash("The session has been updated successfully", "success")
        return redirect(url_for('.display_session_view', session_id=session_id))
开发者ID:codebhendi,项目名称:open-event-orga-server,代码行数:25,代码来源:my_sessions.py

示例10: initiate_order_payment

    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,代码行数:59,代码来源:ticketing.py

示例11: create_default_user

def create_default_user():
    print "Your login is 'super_admin'."
    email = raw_input("Enter email for super_admin    : ")
    _validate_email(email)
    getpass.os = eventlet.patcher.original('os')
    password = getpass.getpass("Enter password for super_admin : ")
    _validate_password(password)
    DataManager.create_super_admin(email, password)
开发者ID:SaptakS,项目名称:open-event-orga-server,代码行数:8,代码来源:create_db.py

示例12: process_event_cfs

def process_event_cfs(identifier, via_hash=False):
    if request.method == 'GET':
        event = get_published_event_or_abort(identifier)
        placeholder_images = DataGetter.get_event_default_images()
        if event.sub_topic:
            custom_placeholder = DataGetter.get_custom_placeholder_by_name(event.sub_topic)
        elif event.topic:
            custom_placeholder = DataGetter.get_custom_placeholder_by_name(event.topic)
        else:
            custom_placeholder = DataGetter.get_custom_placeholder_by_name('Other')
        if not event.has_session_speakers:
            abort(404)

        call_for_speakers = DataGetter.get_call_for_papers(event.id).first()

        if not call_for_speakers or (not via_hash and call_for_speakers.privacy == 'private'):
            abort(404)

        form_elems = DataGetter.get_custom_form_elements(event.id)
        speaker_form = json.loads(form_elems.speaker_form)
        session_form = json.loads(form_elems.session_form)

        now = datetime.now(pytz.timezone(event.timezone
                                                  if (event.timezone and event.timezone != '') else 'UTC'))
        start_date = pytz.timezone(event.timezone).localize(call_for_speakers.start_date)
        end_date = pytz.timezone(event.timezone).localize(call_for_speakers.end_date)
        state = "now"
        if end_date < now:
            state = "past"
        elif start_date > now:
            state = "future"
        speakers = DataGetter.get_speakers(event.id).all()
        user_speaker = DataGetter.get_speaker_by_email_event(login.current_user.email, event.id)
        accepted_sessions_count = get_count(DataGetter.get_sessions(event.id))
        return render_template('gentelella/guest/event/cfs_new_session.html',
                               event=event,
                               speaker_form=speaker_form,
                               user_speaker=user_speaker,
                               accepted_sessions_count=accepted_sessions_count,
                               session_form=session_form,
                               call_for_speakers=call_for_speakers,
                               placeholder_images=placeholder_images,
                               state=state,
                               speakers=speakers,
                               via_hash=via_hash,
                               custom_placeholder=custom_placeholder,
                               from_path="cfs")

    if request.method == 'POST':
        event = DataGetter.get_event_by_identifier(identifier)
        if not event.has_session_speakers:
            abort(404)
        if login.current_user.is_authenticated:
            DataManager.add_session_to_event(request, event.id, no_name=True)
            flash("Your session proposal has been submitted", "success")
            return redirect(url_for('my_sessions.display_my_sessions_view', event_id=event.id))

        return redirect(url_for('admin.login_view', next=url_for('my_sessions.display_my_sessions_view')))
开发者ID:rafalkowalski,项目名称:open-event-orga-server,代码行数:58,代码来源:event_detail.py

示例13: contact_info_view

def contact_info_view():
    user_id = login.current_user.id
    if request.method == 'POST':
        DataManager.update_user(request.form, int(user_id), contacts_only_update=True)
        flash("Your contact info has been updated.", "success")
        return redirect(url_for('.contact_info_view'))
    profile = DataGetter.get_user(int(user_id))

    return render_template('gentelella/users/settings/pages/contact_info.html', user=login.current_user)
开发者ID:SaptakS,项目名称:open-event-orga-server,代码行数:9,代码来源:settings.py

示例14: update_custom_sys_role

def update_custom_sys_role():
    if request.method == 'POST':
        role_name = request.form.get('role_name')
        sys_role = CustomSysRole.query.filter_by(name=role_name).first()
        if not sys_role:
            flash('No such role exists.')
            return redirect(url_for('.index_view'))
        DataManager.update_custom_sys_role(request.form)
    return redirect(url_for('.index_view'))
开发者ID:SaptakS,项目名称:open-event-orga-server,代码行数:9,代码来源:permissions.py

示例15: create_custom_sys_role

def create_custom_sys_role():
    if request.method == 'POST':
        role_name = request.form.get('role_name')
        sys_role = CustomSysRole.query.filter_by(name=role_name).first()
        if sys_role:
            flash('A System Role with similar name already exists. Please choose a different name.')
            return redirect(url_for('.index_view'))
        DataManager.create_custom_sys_role(request.form)
    return redirect(url_for('.index_view'))
开发者ID:SaptakS,项目名称:open-event-orga-server,代码行数:9,代码来源:permissions.py


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