def delete(dataset_id):
    ds = get_dataset(dataset_id)
    if ds["author"] != current_user.id:
        raise Unauthorized("You can't delete this dataset.")
    if request.method == "POST":
        db.dataset.delete(ds["id"])
        flash.success("Dataset has been deleted.")
        return redirect(url_for("user.profile", musicbrainz_id=current_user.musicbrainz_id))
    else:  # GET
        return render_template("datasets/delete.html", dataset=ds)
Example #2
0
def delete(dataset_id):
    ds = get_dataset(dataset_id)
    if ds["author"] != current_user.id:
        raise Unauthorized("You can't delete this dataset.")
    if request.method == "POST":
        db.dataset.delete(ds["id"])
        flash.success("Dataset has been deleted.")
        return redirect(
            url_for("user.profile",
                    musicbrainz_id=current_user.musicbrainz_id))
    else:  # GET
        return render_template("datasets/delete.html", dataset=ds)
Example #3
0
def delete(dataset_id):
    ds = get_dataset(dataset_id)
    if ds["author"] != current_user.id:
        raise Forbidden("You can't delete this dataset.")

    form = FlaskForm()
    if form.validate_on_submit():
        db.dataset.delete(ds["id"])
        flash.success("Dataset has been deleted.")
        return redirect(url_for("user.profile", musicbrainz_id=current_user.musicbrainz_id))
    else:  # GET
        return render_template("datasets/delete.html", dataset=ds, form=form)
 def add(self):
     form = forms.AddAdminForm()
     if form.validate_on_submit():
         try:
             db.user.set_admin(form.musicbrainz_id.data,
                               admin=True,
                               force=form.force.data)
             flash.success("Added an admin: %s." % form.musicbrainz_id.data)
         except db.exceptions.DatabaseException as e:
             flash.error("Error: %s" % e)
             return redirect(url_for(".add"))
         return redirect(url_for(".index"))
     return self.render("admin/admins/add.html", form=form)
Example #5
0
 def add(self):
     form = forms.AddAdminForm()
     if form.validate_on_submit():
         try:
             db.user.set_admin(form.musicbrainz_id.data,
                               admin=True,
                               force=form.force.data)
             flash.success("Added an admin: %s." % form.musicbrainz_id.data)
         except db.exceptions.DatabaseException as e:
             flash.error("Error: %s" % e)
             return redirect(url_for(".add"))
         return redirect(url_for(".index"))
     return self.render("admin/admins/add.html", form=form)