def find_invite(): event_id = request.args.get('event_id') if not Event.find(event_id).is_private: return jsonify({"invite": True}) else: if current_user.is_authenticated: if Event.find(event_id).creator_id == current_user.id: return jsonify({"invite": True}) elif Invite.check_for_invite(event_id, current_user.email): return jsonify({"invite": True}) else: return jsonify({"invite": False}) else: return jsonify({"invite": False})
def create_checkout_session(): company_id = request.get_json(force=True).get('company_id') event = Event.find(Company.find(company_id).event_id) checkout_session = stripe.checkout.Session.create( payment_method_types=['card'], line_items=[ { 'price_data': { 'currency': 'bgn', 'unit_amount': event.payment * 100, 'product_data': { 'name': event.name, # 'images': ['https://i.imgur.com/EHyR2nP.png'], }, }, 'quantity': 1, }, ], mode='payment', success_url="http://localhost:3000/view-company/" + str(current_user.id) + '?success=true', cancel_url="http://localhost:3000/view-company/" + str(current_user.id) + '?canceled=true', ) return jsonify({"id": checkout_session.id})
def join_event(): content = request.get_json(force=True) User.join_event(content.get('user_id'), content.get('event_id')) Event.add_visitor(content.get('event_id')) return jsonify({"joined_event": Event.find(content.get('event_id')).name})
def list_companies(): event_id = request.args.get('event_id') Event.add_visitor(event_id) companies = Company.get_companies_sp_list(event_id) active_companies = [] for company in companies: if Event.find(event_id).subscriptable: if Payment.check_for_payment(event_id, company.id): active_companies.append(company.to_dict()) else: active_companies.append(company.to_dict()) print(active_companies) return jsonify(active_companies)