Ejemplo n.º 1
0
def project_delete(profile, project, event):
    if not lastuser.has_permission('siteadmin') and g.user not in project.users:
        abort(403)
    form = ConfirmDeleteForm()
    if form.validate_on_submit():
        if 'delete' in request.form:
            # FIXME: All of this should cascade. No need to delete one at a time
            members = ProjectMember.query.filter_by(project_id=project.id).all()
            comments = Comment.query.filter_by(commentspace=project.comments).all()
            votes = Vote.query.filter_by(votespace=project.votes).all()
            for comment in comments:
                db.session.delete(comment)
            for vote in votes:
                db.session.delete(vote)
            for member in members:
                db.session.delete(member)
            db.session.delete(project.comments)
            db.session.delete(project.votes)
            db.session.delete(project)
            db.session.commit()
            flash("Project removed", "success")
            return render_redirect(event.url_for(), code=303)
        elif 'cancel' in request.form:
            return render_redirect(project.url_for(), code=303)
    return render_template('baseframe/delete.html', form=form, title=u"Confirm delete",
        message=u"Delete '%s' ? It will remove comments, votes and all information related to the project. This operation cannot be undone." % (project.title))
Ejemplo n.º 2
0
def project_delete(profile, project, event):
    if not lastuser.has_permission(
            'siteadmin') and g.user not in project.users:
        abort(403)
    form = ConfirmDeleteForm()
    if form.validate_on_submit():
        if 'delete' in request.form:
            # FIXME: All of this should cascade. No need to delete one at a time
            members = ProjectMember.query.filter_by(
                project_id=project.id).all()
            comments = Comment.query.filter_by(
                commentspace=project.comments).all()
            votes = Vote.query.filter_by(votespace=project.votes).all()
            for comment in comments:
                db.session.delete(comment)
            for vote in votes:
                db.session.delete(vote)
            for member in members:
                db.session.delete(member)
            db.session.delete(project.comments)
            db.session.delete(project.votes)
            db.session.delete(project)
            db.session.commit()
            flash("Project removed", "success")
            return render_redirect(url_for('event_view',
                                           profile=profile.name,
                                           event=event.name),
                                   code=303)
    return render_template(
        'baseframe/delete.html',
        form=form,
        title=u"Confirm delete",
        message=
        u"Delete '%s' ? It will remove comments, votes and all information related to the project. This operation cannot be undone."
        % (project.title))
Ejemplo n.º 3
0
def venue_delete(venue):
    if not lastuser.has_permission('siteadmin') and venue.profile.userid not in g.user.user_organizations_owned_ids():
        abort(403)
    return render_delete_sqla(venue, db, title=u"Confirm delete",
        message=u"Delete venue '%s'? This cannot be undone." % venue.title,
        success=u"You have deleted playlist '%s'." % venue.title,
        next=url_for('venue_list'))
Ejemplo n.º 4
0
def sponsor_delete(profile, event, sponsor):
    if not lastuser.has_permission('siteadmin') and profile.userid not in g.user.user_organizations_owned_ids():
        abort(403)

    return render_delete_sqla(sponsor, db, title=u"Confirm delete",
        message=u"Delete Sponsor '%s'? This cannot be undone." % sponsor.title,
        success=u"You have deleted the sponsor '%s'." % sponsor.title,
         next=url_for('event_view', profile=profile.name, event=event.name))
Ejemplo n.º 5
0
def sponsor_delete(profile, event, sponsor):
    if not lastuser.has_permission('siteadmin') and profile.userid not in g.user.user_organizations_owned_ids():
        abort(403)

    return render_delete_sqla(sponsor, db, title=u"Confirm delete",
        message=u"Delete Sponsor '%s'? This cannot be undone." % sponsor.title,
        success=u"You have deleted the sponsor '%s'." % sponsor.title,
         next=event.url_for())
Ejemplo n.º 6
0
def venue_delete(venue):
    if not lastuser.has_permission(
            'siteadmin'
    ) and venue.profile.userid not in g.user.user_organizations_owned_ids():
        abort(403)
    return render_delete_sqla(
        venue,
        db,
        title=u"Confirm delete",
        message=u"Delete venue '%s'? This cannot be undone." % venue.title,
        success=u"You have deleted playlist '%s'." % venue.title,
        next=url_for('venue_list'))
Ejemplo n.º 7
0
def venue_edit(venue):
    if not lastuser.has_permission('siteadmin') and venue.profile.userid not in g.user.user_organization_owned_ids():
        abort(403)
    form = VenueForm(obj=venue)
    form.profile_id.choices = [(p.id, p.title) for p in g.user.profiles]
    if form.validate_on_submit():
        form.populate_obj(venue)
        venue.make_name()
        db.session.commit()
        flash(u"You have edited details for venue %s" % venue.title, "success")
        return render_redirect(url_for('venue_view', venue=venue.name), code=303)
    return render_form(form=form, title="Edit Venue", submit=u"Save",
        cancel_url=url_for('venue_view', venue=venue.name), ajax=False)
Ejemplo n.º 8
0
def venue_edit(venue):
    if not (lastuser.has_permission('siteadmin')
            or venue.profile.userid in g.user.user_organizations_owned_ids()):
        abort(403)
    form = VenueForm(obj=venue)
    form.profile_id.choices = [(p.id, p.title) for p in g.user.profiles]
    form.profile_id.choices.insert(0, (venue.profile.id, venue.profile.title))
    if form.validate_on_submit():
        form.populate_obj(venue)
        venue.make_name()
        db.session.commit()
        flash(u"You have edited details for venue %s" % venue.title, "success")
        return render_redirect(url_for('venue_view', venue=venue.name),
                               code=303)
    return render_form(form=form,
                       title="Edit Venue",
                       submit=u"Save",
                       cancel_url=url_for('venue_view', venue=venue.name),
                       ajax=False)