Skip to content

Commit

Permalink
Merge pull request #3 from Veiled-Haven/feat_discord_application
Browse files Browse the repository at this point in the history
feat: replace application form with discord link
  • Loading branch information
KeyboardInterrupt authored Jul 23, 2024
2 parents 6550fcb + e0bded7 commit 1d25757
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 95 deletions.
64 changes: 7 additions & 57 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,14 @@
import os
from flask import Flask, render_template, request, redirect, url_for
from discord_webhook import DiscordWebhook, DiscordEmbed
from flask_bootstrap import Bootstrap4
from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField, TextAreaField, BooleanField, SubmitField, ValidationError
from wtforms.validators import DataRequired, NumberRange
from flask import Flask, render_template

webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', "")
app = Flask(
__name__, static_url_path="", static_folder="static/", template_folder="templates/"
)

app = Flask(__name__,static_url_path='',static_folder='static/',template_folder='templates/')
SECRET_KEY = os.urandom(32)
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?")
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 :(")])
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"])
@app.route("/")
def home():
form = ApplicationForm()
if request.method == "POST" and form.validate_on_submit(): #on form submission
webhook = DiscordWebhook(url=webhook_url)
embed = DiscordEmbed(title='Form Submission')
print(form.data)
for form_field in form.data:
print(f"{form_field}: {form.data[form_field]}")
embed.add_embed_field(name=form_field, value=form.data[form_field])
# add embed object to webhook
webhook.add_embed(embed)
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)

return render_template("index.html")

@app.route("/success")
def success():
return render_template("success.html")

app.run(host='0.0.0.0', port=5000)
app.run(host="0.0.0.0", port=5000)
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
flask
discord-webhook
bootstrap-flask
flask-wtf
Binary file removed static/img/screenshot-dragonfight.jpg
Binary file not shown.
Binary file removed static/img/screenshot-townsquare.jpg
Binary file not shown.
25 changes: 7 additions & 18 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h6>How active is the community?</h6>
</div>
<div class="col-md-6 mb-5">
<h6>Is there any Pay to Win crap on this server?</h6>
<p>Absolutely not! Our server does not have any Pay to Win elements that provide any advantages.</p>
<p>Absolutely not! Our server does not have any Pay to Win elements!</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -144,18 +144,14 @@ <h2 class="text-white heading-black">Rules</h2>
</div>
</section>

{% from 'bootstrap5/form.html' import render_form %}
<!--application section-->
<section class="py-7 bg-dark section-angle top-left bottom-left" id="application">
<div class="container">
<div class="row">
<div class="col-md-6 mx-auto text-center">
<h2 class="heading-black">Application Form!</h2>
</div>
</div>
<div class="row">
<div class="col-md-6 mx-auto">
{{ render_form(form) }}
<div class="col-md-10 mx-auto text-center">
<h2 class="heading-black">Application!</h2>
<p>Ready to dive into the adventure of Veiled Haven? Join our Discord and apply now to start your journey!</p>
<a href="https://discord.com/invite/XBsWNw7zQu" class="btn btn-primary"><i class="fa fa-brands fa-discord"></i> Join Veiled Haven on Discord</a>
</div>
</div>
</div>
Expand All @@ -169,24 +165,17 @@ <h2 class="heading-black">Application Form!</h2>
<h5>Veiled Haven</h5>
<p class="text-muted">A Minecraft Server Project with a focus on keeping a vanilla gameplay experience and maintaining an adult community!</p>
<ul class="list-inline social social-sm">
{#% disable discord social icon as we are invite only!
<li class="list-inline-item">
<a href=""><i class="fa fa-brands fa-discord"></i></a>
<a href="https://discord.com/invite/XBsWNw7zQu"><i class="fa fa-brands fa-discord"></i></a>
</li>
%#}
</ul>
</div>
{#% disable link section for now
<div class="col-sm-2">
<h5>Links</h5>
<ul class="list-unstyled">
<li><a href="https://map.veiled-haven.net">DynMap</a></li>
</ul>
<ul class="list-unstyled">
<li><a href="https://admin.veiled-haven.net">Admin</a></li>
<li><a href="https://map.veiled-haven.net">Map</a></li>
</ul>
</div>
%#}
</div>
<div class="row mt-5">
<div class="col-12 text-muted text-center small-xl">
Expand Down
2 changes: 1 addition & 1 deletion templates/parts/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<a class="nav-link page-scroll" href="#rules">Rules</a>
</li>
<li class="nav-item">
<a class="nav-link page-scroll" href="#application">Application Form</a>
<a class="nav-link page-scroll" href="#application">Application</a>
</li>
</ul>
{% endif %}
Expand Down
16 changes: 0 additions & 16 deletions templates/success.html

This file was deleted.

0 comments on commit 1d25757

Please sign in to comment.