Skip to content

Commit

Permalink
Merge pull request #2 from Veiled-Haven/fix_some_bugs
Browse files Browse the repository at this point in the history
fix: minor bug fixes
  • Loading branch information
KeyboardInterrupt authored Jun 4, 2024
2 parents a22474e + dbb5772 commit 6550fcb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
23 changes: 18 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from discord_webhook import DiscordWebhook, DiscordEmbed
from flask_bootstrap import Bootstrap4
from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField, TextAreaField, BooleanField, SubmitField
from wtforms import StringField, IntegerField, TextAreaField, BooleanField, SubmitField, ValidationError
from wtforms.validators import DataRequired, NumberRange

webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', "")
Expand All @@ -13,18 +13,29 @@
app.config['SECRET_KEY'] = SECRET_KEY
bootstrap = Bootstrap4(app)

class ValidateMath(object):
def __init__(self, message=None):
self.message = message

def __call__(self, form, field):
if field.data != 13:
raise ValidationError(self.message)


class ApplicationForm(FlaskForm):
minecraft_username = StringField("What is your Minecraft username?*",description="We need this information to eventually Whitelist you on the Server!", validators=[DataRequired()])
discord_username = StringField("What is your Discord username?*", description="<b>Please make sure you accept Friend Requests</b>, Discord is where we will get in touch with you!", validators=[DataRequired()])
why_would_you_like_to_join = TextAreaField("Why would you like to join?*", validators=[DataRequired()])
favorite_aspect = TextAreaField("What is your favorite aspect of playing Minecraft online?*", validators=[DataRequired()])
how_long_have_you_played = TextAreaField("How long have you been playing Minecraft?", validators=[DataRequired()])
have_you_been_part_of_an_smp = TextAreaField("Have you been part of any SMP's before, if so why did you leave?", validators=[DataRequired()])
how_long_have_you_played = TextAreaField("How long have you been playing Minecraft?")
have_you_been_part_of_an_smp = TextAreaField("Have you been part of any SMP's before, if so why did you leave?")
age = IntegerField("What is your age?*", validators=[DataRequired(),NumberRange(min=16,max=200,message="Sorry, you are to Young to play with us :(")])
rules_accepted = BooleanField("Do you accept the Rules?", validators=[DataRequired()])
math = IntegerField("What is Five plus Eight?*",validators=[DataRequired(),ValidateMath(message="Are you sure your Math is correct?")])
rules_accepted = BooleanField("Do you accept the Rules?*", validators=[DataRequired()])
submit = SubmitField()



@app.route("/", methods=["GET", "POST"])
def home():
form = ApplicationForm()
Expand All @@ -40,8 +51,10 @@ def home():
if webhook_url != "":
response = webhook.execute()
return redirect(location=url_for("success"),code=302)
elif form.errors:
return render_template("index.html", form=form, anchor=list(form.errors.keys())[0])
else:
return render_template("index.html", form=form,anchor='application')
return render_template("index.html", form=form)


@app.route("/success")
Expand Down
16 changes: 11 additions & 5 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1 class="heading-black text-capitalize"><img src="{{ url_for('static', filenam
</div>
</div>
</section>

{#% disable Screenshot section
<!--screenshot section-->
<section class="py-7 section-angle top-left bottom-left" id="screenshots">
<div class="container">
Expand Down Expand Up @@ -54,16 +54,16 @@ <h2 class="heading-black">Screenshots</h2>
</div>

</div>
{#% disable "View all posts" button as we dont have a galery yet!
<!--
<div class="row mt-6">
<div class="col-md-6 mx-auto text-center">
<a href="#" class="btn btn-primary">View all posts</a>
</div>
</div>
%#}
-->
</div>
</section>

%#}
<!--faq section-->
<section class="py-7 bg-image bg-image-2 bg-hero" id="faq">
<div class="container">
Expand Down Expand Up @@ -200,5 +200,11 @@ <h5>Links</h5>
<div class="scroll-top">
<i class="fa fa-angle-up" aria-hidden="true"></i>
</div>

{% if anchor %}
<script>
document.getElementById('{{ anchor }}').scrollIntoView();
// or
document.location.hash = '#' + '{{ anchor }}';
</script>
{% endif %}
{% include 'parts/tail.html' %}
2 changes: 2 additions & 0 deletions templates/parts/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<li class="nav-item">
<a class="nav-link page-scroll" href="#home">Home</a>
</li>
{#% disable Screenshot section
<li class="nav-item">
<a class="nav-link page-scroll" href="#screenshots">Screenshots</a>
</li>
%#}
<li class="nav-item">
<a class="nav-link page-scroll" href="#faq">FAQ</a>
</li>
Expand Down

0 comments on commit 6550fcb

Please sign in to comment.