remove partner code
This commit is contained in:
parent
01e19485eb
commit
ea123b0922
|
@ -25,13 +25,9 @@ else:
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
|
|
||||||
# Constants
|
|
||||||
PARTNER_CODES = ["SL2019"]
|
|
||||||
|
|
||||||
# Allow user to have 1 year of premium: set the expiration_date to 1 year more
|
# Allow user to have 1 year of premium: set the expiration_date to 1 year more
|
||||||
PROMO_CODE = "SIMPLEISBETTER"
|
PROMO_CODE = "SIMPLEISBETTER"
|
||||||
|
|
||||||
|
|
||||||
# Server url
|
# Server url
|
||||||
URL = os.environ["URL"]
|
URL = os.environ["URL"]
|
||||||
print(">>> URL:", URL)
|
print(">>> URL:", URL)
|
||||||
|
|
|
@ -33,21 +33,6 @@
|
||||||
{{ render_field_errors(form.website) }}
|
{{ render_field_errors(form.website) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Possibility to bypass using promo code. Only applied for user already authenticated -->
|
|
||||||
{% if current_user.is_authenticated %}
|
|
||||||
<hr>
|
|
||||||
<h4 class="text-center">
|
|
||||||
Or if you have a <em>partner code</em>, you can become a partner right away!
|
|
||||||
</h4>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label">Partner Code</label>
|
|
||||||
{{ form.partner_code(class="form-control", type="text", placeholder="Partner Code") }}
|
|
||||||
{{ render_field_errors(form.partner_code) }}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="form-footer">
|
<div class="form-footer">
|
||||||
<button type="submit" class="btn btn-primary btn-block">Become a Partner</button>
|
<button type="submit" class="btn btn-primary btn-block">Become a Partner</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,7 +3,6 @@ from flask_login import current_user
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from wtforms import StringField
|
from wtforms import StringField
|
||||||
|
|
||||||
from app.config import PARTNER_CODES
|
|
||||||
from app.email_utils import notify_admin
|
from app.email_utils import notify_admin
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.models import Partner
|
from app.models import Partner
|
||||||
|
@ -15,7 +14,6 @@ class BecomePartnerForm(FlaskForm):
|
||||||
name = StringField("Name")
|
name = StringField("Name")
|
||||||
website = StringField("Website")
|
website = StringField("Website")
|
||||||
additional_information = StringField("Additional Information")
|
additional_information = StringField("Additional Information")
|
||||||
partner_code = StringField("Partner Code")
|
|
||||||
|
|
||||||
|
|
||||||
@partner_bp.route("/become", methods=["GET", "POST"])
|
@partner_bp.route("/become", methods=["GET", "POST"])
|
||||||
|
@ -23,54 +21,26 @@ def become():
|
||||||
form = BecomePartnerForm(request.form)
|
form = BecomePartnerForm(request.form)
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
# bypass the application
|
partner = Partner.create(
|
||||||
if form.partner_code.data:
|
email=form.email.data,
|
||||||
if not current_user.is_authenticated:
|
name=form.name.data,
|
||||||
raise Exception("only authenticated user can enter partner code")
|
website=form.website.data,
|
||||||
|
additional_information=form.additional_information.data,
|
||||||
|
)
|
||||||
|
|
||||||
if form.partner_code.data in PARTNER_CODES:
|
if current_user.is_authenticated:
|
||||||
notify_admin(
|
partner.user_id = current_user.id
|
||||||
f"User {current_user.name} has become partner!",
|
|
||||||
{current_user.email},
|
|
||||||
)
|
|
||||||
|
|
||||||
current_user.is_developer = True
|
db.session.commit()
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
flash(
|
notify_admin(
|
||||||
"Congratulations, you are now a SimpleLogin partner! "
|
f"New partner {partner.name} {partner.email} has signed up!",
|
||||||
"You will have access to tech resources on SimpleLogin.",
|
partner.website,
|
||||||
"success",
|
)
|
||||||
)
|
|
||||||
|
|
||||||
return redirect(url_for("developer.index"))
|
flash(
|
||||||
else:
|
"Your request has been submitted, we'll come back to you asap!", "success"
|
||||||
error = (
|
)
|
||||||
"The partner code is unknown. Are you sure this is the right code?"
|
|
||||||
)
|
|
||||||
return render_template("partner/become.html", form=form, error=error)
|
|
||||||
else:
|
|
||||||
partner = Partner.create(
|
|
||||||
email=form.email.data,
|
|
||||||
name=form.name.data,
|
|
||||||
website=form.website.data,
|
|
||||||
additional_information=form.additional_information.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
if current_user.is_authenticated:
|
|
||||||
partner.user_id = current_user.id
|
|
||||||
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
notify_admin(
|
|
||||||
f"New partner {partner.name} {partner.email} has signed up!",
|
|
||||||
partner.website,
|
|
||||||
)
|
|
||||||
|
|
||||||
flash(
|
|
||||||
"Your request has been submitted, we'll come back to you asap!",
|
|
||||||
"success",
|
|
||||||
)
|
|
||||||
|
|
||||||
return redirect(url_for("partner.become"))
|
return redirect(url_for("partner.become"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue