Skip to content

Commit

Permalink
Clean up project files and remove captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
julietrb1 committed May 8, 2021
1 parent 96bd339 commit 287d2c8
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 173 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: gunicorn --log-file - stopclutch.wsgi
release: python manage.py migrate --noinput
release: python manage.py makemigrations && python manage.py migrate --noinput
3 changes: 3 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import os
import sys

from dotenv import load_dotenv

if __name__ == "__main__":
load_dotenv()
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "stopclutch.settings")
try:
from django.core.management import execute_from_command_line
Expand Down
21 changes: 0 additions & 21 deletions races/forms.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,7 @@
from captcha.fields import ReCaptchaField
from django import forms
from django.forms.utils import ErrorList
from django_countries import countries
from django_countries.widgets import CountrySelectWidget

from races.models.game import Game
from races.models.player import Player
from stopclutch import settings


class InterestForm(forms.Form):
name = forms.CharField(max_length=50, required=True)
email = forms.EmailField(max_length=100, required=True)
country = forms.ChoiceField(choices=countries, widget=CountrySelectWidget)
comments = forms.CharField(max_length=500, widget=forms.Textarea(attrs={'rows': 2}), required=False)

def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList,
label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None,
renderer=None):
super().__init__(data, files, auto_id, prefix, initial, error_class, label_suffix, empty_permitted, field_order,
use_required_attribute, renderer)

if not settings.DEBUG:
self.fields['captcha'] = ReCaptchaField()


class PlayerCompareForm(forms.Form):
Expand Down
27 changes: 1 addition & 26 deletions races/views/home.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
from django.contrib import messages
from django.shortcuts import render
from django_countries import countries

import emails
from races.forms import InterestForm
from races.models.game import Game
from races.models.player import Player
from races.models.racetime import RaceTime
from races.models.track import Track
from races.models.vehiclemodel import VehicleModel
from stopclutch import settings


def home(request):
Expand All @@ -30,25 +25,5 @@ def home(request):


def faqs(request):
context = {'first_game': Game.objects.order_by('name').first(), 'interest_form': InterestForm()}

if request.method == 'POST':
form = InterestForm(request.POST)
if form.is_valid():
context['interest_form'] = None
email_subject = 'Stopclutch expression of interest'
email_message = '"{:s}" from {:s} ({:s}) has sent you an expression of interest in using Stopclutch publicly.'.format(
form.cleaned_data['name'], dict(countries)[form.cleaned_data['country']], form.cleaned_data['email'])
if form.cleaned_data['comments']:
email_message += '\n\nComments: {:s}'.format(form.cleaned_data['comments'])
if settings.DEBUG:
print('Sending email with subject "{:s}" and body:\n{:s}'.format(email_subject, email_message))
else:
emails.send_html_mail(email_subject, email_message,
(settings.ADMIN_EMAIL_RECIPIENT,))
messages.info(request,
'Thanks! Your expression of interest has been sent, and I\'ll be more than happy to hear from you.')
else:
messages.error(request, form.errors)

context = {'first_game': Game.objects.order_by('name').first()}
return render(request, 'races/faqs.html', context)
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Django~=3.2
dj-database-url
Django~=3.2.2
dj-database-url~=0.5.0
django-appconf~=1.0.4
django-bootstrap4~=3.0.0
django-bootstrap4~=3.0.1
django-compress~=1.0.1
django-countries~=7.1
django-recaptcha~=2.0.6
django-sass-processor~=1.0.0
django-sass-processor~=1.0.1
djangorestframework~=3.12.4
gunicorn~=20.1.0
mysqlclient~=2.0.3
Pillow~=8.2.0
psycopg2-binary~=2.8.6
psycopg2~=2.8.6
python-dotenv ~= 0.17.1
pytz~=2021.1
whitenoise~=5.2.0
18 changes: 18 additions & 0 deletions stopclutch/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
ASGI config for stopclutch project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application
from dotenv import load_dotenv

load_dotenv()
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "stopclutch.settings")

application = get_asgi_application()
26 changes: 1 addition & 25 deletions stopclutch/settings.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,14 @@
import os
import dj_database_url

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# from stopclutch.secrets import *

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
IS_TEST = 'TRAVIS' in os.environ
IS_PRODUCTION = 'PROD' in os.environ
DEBUG = not IS_TEST and not IS_PRODUCTION
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS').split() if IS_PRODUCTION else []

# if IS_TEST:
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.mysql',
# 'NAME': 'travis_ci_test',
# 'USER': 'postgres',
# 'PASSWORD': '',
# 'HOST': '127.0.0.1',
# 'PORT': '5432',
# }
# }

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'djangodatabase',
'USER': 'dbadmin',
'PASSWORD': '12345',
'HOST': 'localhost',
'PORT': '3306',
}
'default': dj_database_url.config(conn_max_age=600, ssl_require=IS_PRODUCTION or IS_TEST)
}

SECRET_KEY = os.getenv('SECRET_KEY') if IS_PRODUCTION else '!*8(_j2!%+nb14fd(4r+k-*&0t3e19hxh@dr=#tvl1x^4in$sy'
Expand All @@ -46,7 +24,6 @@
'django.contrib.humanize',
'bootstrap4',
'rest_framework',
'captcha',
'django_countries'
]

Expand Down Expand Up @@ -127,6 +104,5 @@
}
}

SILENCED_SYSTEM_CHECKS = [None if IS_TEST else 'captcha.recaptcha_test_key_error']
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
16 changes: 0 additions & 16 deletions stopclutch/settings_dev.py

This file was deleted.

12 changes: 0 additions & 12 deletions stopclutch/settings_prod.py

This file was deleted.

2 changes: 2 additions & 0 deletions stopclutch/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import os

from django.core.wsgi import get_wsgi_application
from dotenv import load_dotenv

load_dotenv()
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "stopclutch.settings")

application = get_wsgi_application()
33 changes: 1 addition & 32 deletions templates/races/faqs.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,6 @@ <h2>Who gets to be a player?</h2>
<h2>Can I use Stopclutch?</h2>
<p>Sure, come visit me. But seriously, it's currently a "closed" project in the sense that it's not technically open
for complete public consumption. Obviously you're consuming it if you're reading this, but it's read-only data
for the timebeing. After gauging public interest regarding others submitting their times, I'll consider making
for the time being. After gauging public interest regarding others submitting their times, I'll consider making
it available for the public.</p>

<h2>Express your interest</h2>
{% if interest_form %}
<form method="post">
{% csrf_token %}
<div class="row">
<div class="col-sm-6">
{% bootstrap_field interest_form.name placeholder='e.g. Eric Diaz' %}
</div>
<div class="col-sm-6">
{% bootstrap_field interest_form.email placeholder='e.g. [email protected]' %}
</div>
<div class="col-sm-6">
{% bootstrap_field interest_form.country %}
</div>
<div class="col-sm-6">
{% bootstrap_field interest_form.comments placeholder="Anything you'd like to let me know?" %}
</div>
<div class="col-sm-6">
{% if interest_form.captcha %}
{{ interest_form.captcha }}
{% endif %}
</div>
</div>
<input type="submit" class="btn btn-success" value="Express my interest">
</form>
{% else %}
<p class="text-success">Thanks! Your expression of interest has been sent, and I'll be more than happy to hear
from you.</p>
{% endif %}

{% endblock %}

0 comments on commit 287d2c8

Please sign in to comment.