def access_codes_delete(event_id, access_code_id=None): access_code = TicketingManager.get_access_code(event_id, access_code_id) if not access_code: abort(404) delete_from_db(access_code, "Access code deleted") flash("The access code has been deleted.", "warning") return redirect(url_for('.access_codes_view', event_id=event_id))
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)
def delete(event_id, speaker_id): speaker = get_speaker_or_throw(speaker_id) speakers_modified.send(current_app._get_current_object(), event_id=speaker.event_id) delete_from_db(speaker, 'Speaker Rejected') flash("The speaker has been deleted", "danger") return redirect(url_for('.index_view', event_id=event_id))
def discount_codes_delete(self, discount_code_id=None): discount_code = InvoicingManager.get_discount_code(discount_code_id) if not discount_code: abort(404) delete_from_db(discount_code, "Discount code deleted") flash("The discount code has been deleted.", "warning") return redirect(url_for('.discount_codes_view'))
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.")
def discount_codes_delete(discount_code_id=None): discount_code = InvoicingManager.get_discount_code(discount_code_id) if not discount_code: abort(404) delete_from_db(discount_code, "Discount code deleted") flash("The discount code has been deleted.", "warning") return redirect(url_for('.discount_codes_view'))
def delete_view(user_id): profile = DataGetter.get_user(user_id) if request.method == "GET": transaction = transaction_class(Event) transaction.query.filter_by(user_id=user_id).delete() delete_from_db(profile, "User's been permanently removed") flash("User" + user_id + " has been permanently deleted.", "danger") return redirect(url_for('.index_view'))
def delete_view(user_id): profile = DataGetter.get_user(user_id) if profile.is_super_admin: abort(403) if request.method == "GET": transaction = transaction_class(Event) transaction.query.filter_by(user_id=user_id).delete() delete_from_db(profile, "User's been permanently removed") flash("User" + user_id + " has been permanently deleted.", "danger") return redirect(url_for('.index_view'))
def delete_user_role_invite(event_id, hash): event = DataGetter.get_event(event_id) role_invite = DataGetter.get_event_role_invite(event.id, hash) if role_invite: delete_from_db(role_invite, 'Deleted RoleInvite') flash('Invitation link has been successfully deleted.') return redirect(url_for('.details_view', event_id=event.id)) else: abort(404)
def delete_model(model, item_id, event_id=None): """ Deletes a model If event_id is set, it is assumed to be a service model """ if event_id is not None: item = get_object_in_event(model, item_id, event_id) else: item = get_object_or_404(model, item_id) if hasattr(item, 'deleted_at'): item.deleted_at = datetime.now() save_to_db(item, '{} moved to trash'.format(model.__name__)) else: delete_from_db(item, '{} deleted'.format(model.__name__)) return item
def delete_model(model, item_id, event_id=None): """ Deletes a model If event_id is set, it is assumed to be a service model """ if event_id is not None: item = get_object_in_event(model, item_id, event_id) else: item = get_object_or_404(model, item_id) if hasattr(item, 'in_trash'): item.in_trash = True save_to_db(item, '{} moved to trash'.format(model.__name__)) else: delete_from_db(item, '{} deleted'.format(model.__name__)) return item
def empty_trash(): with app.app_context(): events = Event.query.filter_by(in_trash=True) users = User.query.filter_by(in_trash=True) sessions = Session.query.filter_by(in_trash=True) for event in events: if datetime.now() - event.trash_date >= timedelta(days=30): DataManager.delete_event(event.id) for user in users: if datetime.now() - user.trash_date >= 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_.trash_date >= timedelta(days=30): delete_from_db(session_, "Session deleted permanently")
def user_role_invite_decline(event_id, hash): """Decline 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)) DataManager.decline_role_invite(role_invite) flash('You have declined the role invite.') return redirect(url_for('.details_view', event_id=event.id)) else: abort(404)
def empty_trash(): from app import current_app as app with app.app_context(): events = Event.query.filter_by(in_trash=True) users = User.query.filter_by(in_trash=True) sessions = Session.query.filter_by(in_trash=True) orders = Order.query.filter_by(status="deleted") pending_orders = Order.query.filter_by(status="pending") expired_orders = Order.query.filter_by(status="expired") for event in events: if datetime.now() - event.trash_date >= timedelta(days=30): DataManager.delete_event(event.id) for user in users: if datetime.now() - user.trash_date >= 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_.trash_date >= timedelta(days=30): delete_from_db(session_, "Session deleted permanently") for order in orders: if datetime.now() - order.trashed_at >= timedelta(days=30): delete_from_db(order, "Order 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.") for expired_order in expired_orders: if datetime.now() - expired_order.created_at >= timedelta(days=6): expired_order.status = "deleted" expired_order.trashed_at = datetime.now() save_to_db(expired_order, "Expired order deleted")
def trash_view(page_id): page = DataGetter.get_page_by_id(page_id) delete_from_db(page, "Page has already deleted") return redirect(url_for('sadmin_content.index_view'))
def delete_session(event_id, session_id): session = get_session_or_throw(session_id) delete_from_db(session, 'Session Deleted') flash("The session has been permanently deleted", "danger") return redirect( url_for('sadmin_sessions.display_my_sessions_view', event_id=event_id))
def delete(event_id, speaker_id): speaker = get_speaker_or_throw(speaker_id) delete_from_db(speaker, 'Speaker Rejected') flash("The speaker has been deleted", "danger") return redirect(url_for('.index_view', event_id=event_id))
def index_view(): if request.method == 'POST': if 'super_admin_email' in request.form: super_admin = DataGetter.get_super_admin_user() super_admin.email = request.form['super_admin_email'] save_to_db(super_admin) if 'event-thumbnail_width' in request.form: im_size_profile = DataGetter.get_image_sizes_by_type(type='profile') im_size_event = DataGetter.get_image_sizes_by_type(type='event') if im_size_profile and im_size_event: im_size_profile.full_width = request.form['profile-large_width'] im_size_profile.full_height = request.form['profile-large_width'] im_size_profile.full_aspect = request.form.get('profile-large_aspect', 'off') im_size_profile.full_quality = request.form['profile-large_quality'] im_size_profile.icon_width = request.form['profile-icon_width'] im_size_profile.icon_height = request.form['profile-icon_width'] im_size_profile.icon_aspect = request.form.get('profile-icon_aspect', 'off') im_size_profile.icon_quality = request.form['profile-icon_quality'] im_size_profile.thumbnail_width = request.form['profile-thumbnail_width'] im_size_profile.thumbnail_height = request.form['profile-thumbnail_width'] im_size_profile.thumbnail_aspect = request.form.get('profile-thumbnail_aspect', 'off') im_size_profile.thumbnail_quality = request.form['profile-thumbnail_quality'] im_size_profile.logo_width = None im_size_profile.logo_height = None save_to_db(im_size_profile, "Image Sizes saved") im_size_event.full_width = request.form['event-large_width'] im_size_event.full_height = request.form['event-large_height'] im_size_event.full_aspect = request.form.get('event-large_aspect', 'off') im_size_event.full_quality = request.form['event-large_quality'] im_size_event.icon_width = request.form['event-icon_width'] im_size_event.icon_height = request.form['event-icon_height'] im_size_event.icon_aspect = request.form.get('event-icon_aspect', 'off') im_size_event.icon_quality = request.form['event-icon_quality'] im_size_event.thumbnail_width = request.form['event-thumbnail_width'] im_size_event.thumbnail_height = request.form['event-thumbnail_height'] im_size_event.thumbnail_aspect = request.form.get('event-thumbnail_aspect', 'off') im_size_event.thumbnail_quality = request.form['event-thumbnail_quality'] im_size_event.logo_width = request.form['logo_width'] im_size_event.logo_height = request.form['logo_height'] save_to_db(im_size_event, "Image Sizes saved") else: all_im_sizes = DataGetter.get_image_sizes() for sizes in all_im_sizes: delete_from_db(sizes, 'Delete Image Sizes') im_size = ImageSizes(type='profile', full_width=request.form['profile-large_width'], full_height=request.form['profile-large_width'], full_aspect=request.form.get('profile-large_aspect', 'off'), full_quality=request.form['profile-large_quality'], icon_width=request.form['profile-icon_width'], icon_height=request.form['profile-icon_width'], icon_aspect=request.form.get('profile-icon_aspect', 'off'), icon_quality=request.form['profile-icon_quality'], thumbnail_width=request.form['profile-thumbnail_width'], thumbnail_height=request.form['profile-thumbnail_width'], thumbnail_aspect=request.form.get('profile-thumbnail_aspect', 'off'), thumbnail_quality=request.form['profile-thumbnail_quality'], logo_width=None, logo_height=None) save_to_db(im_size, "Image Sizes saved") im_size = ImageSizes(type='event', full_width=request.form['event-large_width'], full_height=request.form['event-large_height'], full_aspect=request.form.get('event-large_aspect', 'off'), full_quality=request.form['profile-large_quality'], icon_width=request.form['event-icon_width'], icon_height=request.form['event-icon_height'], icon_aspect=request.form.get('event-icon_aspect', 'off'), icon_quality=request.form['profile-icon_quality'], thumbnail_width=request.form['event-thumbnail_width'], thumbnail_height=request.form['event-thumbnail_height'], thumbnail_aspect=request.form.get('event-thumbnail_aspect', 'off'), thumbnail_quality=request.form['profile-thumbnail_quality'], logo_width=request.form['logo_width'], logo_height=request.form['logo_height']) save_to_db(im_size, "Image Sizes saved") if 'service_fee' in request.form: dic = ImmutableMultiDict(request.form) else: dic = dict(request.form.copy()) for i in dic: v = dic[i][0] if not v: dic[i] = None else: dic[i] = v set_settings(**dic) settings = get_settings() fees = DataGetter.get_fee_settings() image_config = DataGetter.get_image_configs() event_image_sizes = DataGetter.get_image_sizes_by_type(type='event') profile_image_sizes = DataGetter.get_image_sizes_by_type(type='profile') return render_template( 'gentelella/admin/super_admin/settings/settings.html', settings=settings, fees=fees, s3_regions=boto.s3.regions(), payment_currencies=DataGetter.get_payment_currencies(), included_settings=get_module_settings(), image_config=image_config, super_admin_email=DataGetter.get_super_admin_user().email, event_image_sizes=event_image_sizes, profile_image_sizes=profile_image_sizes, navigation_bar=list_navbar() )
def delete_view(self, event_id, sponsor_id): sponsor = DataGetter.get_sponsor(sponsor_id) delete_from_db(sponsor, "Sponsor deleted") return redirect(url_for('events.details_view', event_id=event_id))
def delete_session(event_id, session_id): session = get_session_or_throw(session_id) delete_from_db(session, 'Session Deleted') flash("The session has been permanently deleted", "danger") return redirect(url_for('sadmin_sessions.display_my_sessions_view', event_id=event_id))
def delete_view(event_id, sponsor_id): sponsor = DataGetter.get_sponsor(sponsor_id) delete_from_db(sponsor, "Sponsor deleted") return redirect(url_for('events.details_view', event_id=event_id))