Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit: Added Trello URL in README.md #128

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "C:\\Users\\telhu\\.virtualenvs\\Intro-Django-WLVi3cbh\\Scripts\\python.exe"
}
1 change: 1 addition & 0 deletions LambdaMUD-Client
Submodule LambdaMUD-Client added at 1a3127
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ django-cors-headers = "*"
gunicorn = "*"
django-heroku = "*"
django-rest-api = "*"
psycopg2-binary = "*"
whitenoise = "*"
dj-database-url = "*"

[dev-packages]

Expand Down
216 changes: 124 additions & 92 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ creative guide.
- [ ] Share your board with the project manager that has been assigned to you. If you have not been assigned yet, reach out to your lead PM for guidance
- [ ] Add your Trello URL to your project's README.md file. Commit the change, push it to your repository & submit a pull request

https://trello.com/b/6Sp67zaD/lambdamud-tsai

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that you put your trello link in here. It's a small thing but a lot of students forget to do this, but it's really important for communicating your work so great job.


## MVP Features:

#### Client
Expand Down
27 changes: 22 additions & 5 deletions adv_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import os
from decouple import config
import dj_database_url

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand All @@ -26,7 +27,11 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', cast=bool)

ALLOWED_HOSTS = []
ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
'lambda-mud-tsaihuang.herokuapp.com'
]


# Application definition
Expand Down Expand Up @@ -55,6 +60,7 @@

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down Expand Up @@ -90,12 +96,18 @@
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# }
}

DATABASES['default'] = dj_database_url.config(default=config('DATABASE_URL'), conn_max_age=600)

# db_from_env = dj_database_url.config(conn_max_age=500)
# DATABASES['default'].update(db_from_env)

# DATABASES['default'] = dj_database_url.config(default = config('DATABASE_URL'), conn_max_age=600)

# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
Expand Down Expand Up @@ -151,3 +163,8 @@

import django_heroku
django_heroku.settings(locals())
del DATABASES['default']['OPTIONS']['sslmode'] # <-- Add this line

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
4 changes: 3 additions & 1 deletion adv_project/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.contrib import admin
from django.urls import path, include
from django.urls import path, include, re_path
from django.conf.urls import include
from rest_framework.authtoken import views

urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('api.urls')),
path('api/adv/', include('adventure.urls')),
re_path(r'^api-token-auth/', views.obtain_auth_token)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice how you implemented an authentication route here.

]
15 changes: 13 additions & 2 deletions adventure/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,16 @@ def move(request):
@csrf_exempt
@api_view(["POST"])
def say(request):
# IMPLEMENT
return JsonResponse({'error':"Not yet implemented"}, safe=True, status=500)
player = request.user.player
player_name = player.user.username
player_uuid = player.uuid
player_id = player.id
data = json.loads(request.body)
message = data['message']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a small thing, but have you thought about how you might handle the case where a user submits a blank message or a malicious code? It's definitely stretch but it could interesting to think about.


pusher.trigger(f'p-channel-{player_uuid}', u'broadcast', {'name':f'{player_name}', 'message':f'{message}'})

return JsonResponse({'message':f"{player_name} says \'{message}\'"}, safe=True)



39 changes: 39 additions & 0 deletions adventure/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 2.1.1 on 2018-12-10 22:23

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Player',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('currentRoom', models.IntegerField(default=0)),
('uuid', models.UUIDField(default=uuid.uuid4, unique=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Room',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(default='DEFAULT TITLE', max_length=50)),
('description', models.CharField(default='DEFAULT DESCRIPTION', max_length=500)),
('n_to', models.IntegerField(default=0)),
('s_to', models.IntegerField(default=0)),
('e_to', models.IntegerField(default=0)),
('w_to', models.IntegerField(default=0)),
],
),
]
3 changes: 3 additions & 0 deletions adventure/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from django.conf.urls import url
from . import api
from rest_framework.authtoken import views
from django.urls import path, include, re_path

urlpatterns = [
url('init', api.initialize),
url('move', api.move),
url('say', api.say),
#re_path(r'^api-token-auth/', views.obtain_auth_token)
]
4 changes: 3 additions & 1 deletion api/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django.urls import include, path
from django.urls import include, path, re_path
from django.conf.urls import url
from rest_framework.authtoken import views

urlpatterns = [
path('', include('rest_auth.urls')),
path('registration/', include('rest_auth.registration.urls')),
# re_path(r'^api-token-auth/', views.obtain_auth_token)
]
50 changes: 27 additions & 23 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
asn1crypto==0.24.0
certifi==2018.8.24
astroid==2.1.0
bokeh==1.0.1
certifi==2018.11.29
cffi==1.11.5
chardet==3.0.4
cryptography==2.3.1
defusedxml==0.5.0
dj-database-url==0.5.0
Django==2.1.1
django-allauth==0.37.1
django-cors-headers==2.4.0
django-heroku==0.3.1
django-rest-api==0.1.5
django-rest-auth==0.9.3
djangorestframework==3.8.2
gunicorn==19.9.0
idna==2.7
colorama==0.4.1
cryptography==2.4.2
idna==2.8
isort==4.3.4
Jinja2==2.10
lazy-object-proxy==1.3.1
MarkupSafe==1.1.0
mccabe==0.6.1
ndg-httpsclient==0.5.1
oauthlib==2.1.0
psycopg2==2.7.5
pusher==2.0.1
numpy==1.15.4
packaging==18.0
Pillow==5.3.0
pipenv==2018.11.26
pusher==2.0.2
pyasn1==0.4.4
pycparser==2.19
pylint==2.2.0
pyOpenSSL==18.0.0
python-decouple==3.1
python3-openid==3.1.0
pytz==2018.5
requests==2.19.1
requests-oauthlib==1.0.0
pyparsing==2.3.0
python-dateutil==2.7.5
pytz==2018.7
PyYAML==3.13
requests==2.21.0
six==1.11.0
urllib3==1.23
whitenoise==4.1
tornado==5.1.1
urllib3==1.24.1
virtualenv==16.1.0
virtualenv-clone==0.4.0
wrapt==1.10.11