def manage_subscription(uuid): subscription = Subscription.get(uuid=uuid) if not subscription: abort(404) if not subscription.verified: Subscription.verify_email(subscription.email_verification_token) return render_template("edit_subscription.html", subscription=json.dumps(subscription.to_dict()))
def edit_subscription(uuid): data = json.loads(request.data) subscription = Subscription.update_subscription(uuid, name=data.get('name')) return json.dumps(subscription.to_dict()), 200, { 'Content-Type': 'application/json' }
def admin_subscription_delete_category(subscription_uuid, category_uuid): SubscriptionCategory.delete(subscription_uuid=subscription_uuid, category_uuid=category_uuid) subscription = Subscription.get(uuid=subscription_uuid) return json.dumps(subscription.to_dict()), 200, { 'Content-Type': 'application/json' }
def subscribe(): data = json.loads(request.data) if not data.get("email"): return json.dumps({"message": "An email address is required."}), 200, {"content-type": "application/json"} subscription, message = Subscription.create_or_update(data.get("email"), name=data.get("name")) message = {"message": message} return json.dumps(message), 200, {"content-type": "application/json"}
def admin_subscription_add_category(subscription_uuid): category_uuid = json.loads(request.data).get('category_uuid') SubscriptionCategory.create(subscription_uuid=subscription_uuid, category_uuid=category_uuid) subscription = Subscription.get(uuid=subscription_uuid) return json.dumps(subscription.to_dict()), 200, { 'Content-Type': 'application/json' }
def subscribe(): data = json.loads(request.data) if not data.get('email'): return json.dumps({'message': 'An email address is required.'}), 200, { 'content-type': 'application/json' } subscription, message = Subscription.create_or_update( data.get('email'), name=data.get('name')) message = {"message": message} return json.dumps(message), 200, {'content-type': 'application/json'}
def get_subscriptions(): subscriptions = Subscription.get_list(sort_by='created_at', desc=True, to_json=True) return json.dumps(subscriptions), 200, {'Content-Type': 'application/json'}
import sys from app import app from app.db.subscriptions import Subscription from app.db.galleries import Gallery if __name__ == "__main__": email = sys.argv[1] gallery_uuid = sys.argv[2] gallery = Gallery.get(uuid=gallery_uuid) with app.app_context(): Subscription.send_subscription_email(email, gallery)
def send_emails(uuid): gallery = Gallery.get(uuid=uuid) Subscription.send_subscription_emails(gallery)
def cancel_subscription(uuid): subscription = Subscription.get(uuid=uuid) subscription = Subscription.cancel_subscription(uuid) return redirect('/subscription/{}'.format(subscription.uuid))
def verify_email(verification_code): subscription = Subscription.verify_email(verification_code) if not subscription: abort(404) return redirect('/subscription/{}'.format(subscription.uuid))
def api_cancel_subscription(uuid): subscription = Subscription.cancel_subscription(uuid) return json.dumps(subscription.to_dict()), 200, { 'Content-Type': 'application/json' }
def subscription_add_category(subscription_uuid): category_uuid = json.loads(request.data).get("category_uuid") SubscriptionCategory.create(subscription_uuid=subscription_uuid, category_uuid=category_uuid) subscription = Subscription.get(uuid=subscription_uuid) return json.dumps(subscription.to_dict()), 200, {"Content-Type": "application/json"}
def edit_subscription(uuid): data = json.loads(request.data) subscription = Subscription.update_subscription(uuid, name=data.get("name")) return json.dumps(subscription.to_dict()), 200, {"Content-Type": "application/json"}
def admin_subscription_add_category(subscription_uuid): category_uuid = json.loads(request.data).get('category_uuid') SubscriptionCategory.create(subscription_uuid=subscription_uuid, category_uuid=category_uuid) subscription = Subscription.get(uuid=subscription_uuid) return json.dumps(subscription.to_dict()), 200, {'Content-Type': 'application/json'}
def verify_subscription(uuid): subscription = Subscription.get(uuid=uuid) subscription.send_verification_email() return json.dumps(subscription.to_dict()), 200, {'Content-Type': 'application/json'}
def api_cancel_subscription(uuid): subscription = Subscription.cancel_subscription(uuid) return json.dumps(subscription.to_dict()), 200, {"Content-Type": "application/json"}
def verify_subscription(uuid): subscription = Subscription.get(uuid=uuid) subscription.send_verification_email() return json.dumps(subscription.to_dict()), 200, { 'Content-Type': 'application/json' }
def subscription_delete_category(subscription_uuid, category_uuid): SubscriptionCategory.delete(subscription_uuid=subscription_uuid, category_uuid=category_uuid) subscription = Subscription.get(uuid=subscription_uuid) return json.dumps(subscription.to_dict()), 200, {"Content-Type": "application/json"}