-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from evinjaff/issue-4
Resolve Issue 4 and others
- Loading branch information
Showing
42 changed files
with
17,997 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,3 +398,7 @@ FodyWeavers.xsd | |
*.sln.iml | ||
|
||
server/venv/ | ||
|
||
.DS_Store | ||
|
||
server/egglocke/db.sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Use Python 3 as a base image | ||
FROM python:3 | ||
|
||
# Set the working directory to /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
# install dependencies | ||
COPY requirements.txt ./ | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# copy the current directory contents into the container at /usr/src/app | ||
COPY . /usr/src/app | ||
|
||
# TODO: add production settings for Django | ||
|
||
# run and make migrations | ||
RUN python manage.py makemigrations | ||
RUN python manage.py migrate | ||
|
||
# set debug to false | ||
ENV DEBUG=False | ||
|
||
# run debug server | ||
CMD [ "python", "./manage.py", "runserver", "0.0.0.0:8000" ] | ||
|
||
EXPOSE 8000 | ||
# debug, expose all ports | ||
EXPOSE 0-65535 | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
docker build -t server . | ||
|
||
docker run -d -it -p 8000:8000 server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
from http import HTTPStatus | ||
|
||
|
||
class RobotTxtTests(TestCase): | ||
def test_robots_txt_view(self): | ||
response = self.client.get("/robots.txt") | ||
|
||
assert response.status_code == HTTPStatus.OK | ||
assert response["content-type"] == "text/plain" | ||
|
||
valid_user_agent_headers = [ "User-Agent", "user-agent", "USER-AGENT", "User-agent" ] | ||
valid_header_seen = False | ||
|
||
for header in valid_user_agent_headers: | ||
if header in response.content.decode(): | ||
valid_header_seen = True | ||
break | ||
|
||
assert valid_header_seen | ||
|
||
def test_cannot_access_robots_txt_view_with_post(self): | ||
response = self.client.post("/robots.txt") | ||
self.assertEqual(response.status_code, 405) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. | ||
from .models import Question | ||
from .models import Pokemon, Submitter | ||
|
||
admin.site.register(Question) | ||
admin.site.register(Pokemon) | ||
admin.site.register(Submitter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import json | ||
|
||
# Constants | ||
|
||
ALL_POKEMON_NAMES = [ | ||
] | ||
|
||
MAX_POKEDEX_DICT = { | ||
1: 151, | ||
2: 251, | ||
3: 386, | ||
4: 493, | ||
5: 649, | ||
6: 721, | ||
7: 809, | ||
8: 898, | ||
} | ||
|
||
POKEMON_NAME_TO_ID = { | ||
} | ||
|
||
def import_json(filepath): | ||
with open(filepath, 'r') as f: | ||
data = json.load(f) | ||
return data | ||
|
||
|
||
def main(): | ||
|
||
# Derive constant JSON files from static/pokepoll/pokemdex.json | ||
pokedex = import_json('static/pokepoll/pokedex.json') | ||
|
||
# file 1: all_pokemon_names.json | ||
all_pokemon_names = [] | ||
for pokemon in pokedex: | ||
all_pokemon_names.append(pokemon['name']["english"]) | ||
|
||
# file 2: pokemon_name_to_id.json | ||
pokemon_name_to_id = {} | ||
for pokemon in pokedex: | ||
pokemon_name_to_id[pokemon['name']["english"]] = pokemon['id'] | ||
|
||
with open('static/pokepoll/pokemon_name_to_id.json', 'w') as f: | ||
json.dump(pokemon_name_to_id, f) | ||
|
||
with open('static/pokepoll/all_pokemon_names.json', 'w') as f: | ||
json.dump(all_pokemon_names, f) | ||
|
||
|
||
|
||
|
||
if __name__ == '__main__': | ||
main() |
17 changes: 17 additions & 0 deletions
17
server/egglocke/pokepoll/migrations/0002_rename_question_pokemon.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 5.0.6 on 2024-05-27 04:25 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pokepoll', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameModel( | ||
old_name='Question', | ||
new_name='Pokemon', | ||
), | ||
] |
41 changes: 41 additions & 0 deletions
41
server/egglocke/pokepoll/migrations/0003_submitter_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 5.0.6 on 2024-05-27 04:47 | ||
|
||
import django.db.models.deletion | ||
import pokepoll.models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pokepoll', '0002_rename_question_pokemon'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Submitter', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=200)), | ||
('email', models.EmailField(max_length=254)), | ||
], | ||
), | ||
migrations.RenameField( | ||
model_name='pokemon', | ||
old_name='question_text', | ||
new_name='pokemon_nickname', | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_species', | ||
field=models.IntegerField(default=1), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='submitter', | ||
field=models.ForeignKey(default=pokepoll.models.Submitter.get_default_parent_key, on_delete=django.db.models.deletion.CASCADE, to='pokepoll.submitter'), | ||
), | ||
migrations.DeleteModel( | ||
name='Choice', | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
server/egglocke/pokepoll/migrations/0004_alter_submitter_email.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.0.6 on 2024-05-27 08:30 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pokepoll', '0003_submitter_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='submitter', | ||
name='email', | ||
field=models.EmailField(max_length=254, unique=True), | ||
), | ||
] |
73 changes: 73 additions & 0 deletions
73
server/egglocke/pokepoll/migrations/0005_pokemon_pokemon_ev_pokemon_pokemon_iv_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Generated by Django 5.0.6 on 2024-05-27 09:35 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pokepoll', '0004_alter_submitter_email'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_EV', | ||
field=models.JSONField(default=list), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_IV', | ||
field=models.JSONField(default=list), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_OT', | ||
field=models.CharField(default='Red', max_length=10), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_OTGender', | ||
field=models.IntegerField(default=1), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_ability', | ||
field=models.IntegerField(default=1), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_ball', | ||
field=models.IntegerField(default=1), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_language', | ||
field=models.IntegerField(default=2), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_moves', | ||
field=models.JSONField(default=list), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_movespp', | ||
field=models.JSONField(default=list), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='pokemon_nature', | ||
field=models.IntegerField(default=1), | ||
), | ||
migrations.AddField( | ||
model_name='pokemon', | ||
name='upvotes', | ||
field=models.IntegerField(default=0), | ||
), | ||
migrations.AlterField( | ||
model_name='pokemon', | ||
name='pokemon_nickname', | ||
field=models.CharField(default='', max_length=10), | ||
), | ||
] |
23 changes: 23 additions & 0 deletions
23
...er/egglocke/pokepoll/migrations/0006_alter_pokemon_pokemon_ev_alter_pokemon_pokemon_iv.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 5.0.6 on 2024-05-27 09:38 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pokepoll', '0005_pokemon_pokemon_ev_pokemon_pokemon_iv_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='pokemon', | ||
name='pokemon_EV', | ||
field=models.JSONField(default=[0, 0, 0, 0, 0, 0]), | ||
), | ||
migrations.AlterField( | ||
model_name='pokemon', | ||
name='pokemon_IV', | ||
field=models.JSONField(default=[31, 31, 31, 31, 31, 31]), | ||
), | ||
] |
Oops, something went wrong.