def ajax_subscribe(): """ Called remotely to subscribe current user to a vendor """ if not current_user.is_authenticated(): abort(403) vendor_id = request.form['vendor_id'] app.logger.debug("Subscribe user to %s" % vendor_id) try: new_vendor = Vendor.objects(id=vendor_id).first() current_user.add_vendor_to_subscriptions(new_vendor) except Exception as inst: app.logger.error("Could not subscribe user %s: %s" % (type(inst), type)) abort(500) return ""
def ajax_unsubscribe(): """ Called remotely to unsubscribe current user from vendor """ if not current_user.is_authenticated(): abort(403) vendor_id = request.form['vendor_id'] app.logger.debug("Unsubscribe user from %s" % vendor_id) try: vendor = Vendor.objects(id=vendor_id).first() current_user.remove_vendor_from_subscriptions(vendor) except Exception as inst: app.logger.error("Could not unsubscribe user %s: %s" % (type(inst), type)) abort(500) return ""
def subscriptions(): return render_template('subscriptions.html', tab="subscriptions", date=datetime.now(), vendors=Vendor.objects())