def advertisements_create(): """This function handles the /users/create endpoint for the blueprint It allows PNT-Admins to create users. It uses the :ref:`users-forms-label` to display UsersCreateForm :returns: users/index.html :rtype: template """ ad = Advertisement() form = AdvertisementCreateForm() if form.validate_on_submit(): form.populate_obj(ad) ad.asset_location = s3_upload(form.ad_file) db.session.add(ad) db.session.commit() return redirect(url_for("advertisements.home")) return render_template("advertisements/create.html", form=form, admin=True)
def advertisements_delete(ad_id): """This function handles the /users/create endpoint for the blueprint It allows PNT-Admins to create users. It uses the :ref:`users-forms-label` to display UsersCreateForm :returns: users/index.html :rtype: template """ ad = Advertisement.by_id(ad_id) db.session.delete(ad) db.session.commit() return redirect(url_for("advertisements.home"))