diff --git a/.gitignore b/.gitignore index 5e7d5cd..f99362a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -perks +static/perks diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..49ef255 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1 @@ +db.sqlite3 diff --git a/backend/db.sqlite3 b/backend/db.sqlite3 deleted file mode 100644 index 345625b..0000000 Binary files a/backend/db.sqlite3 and /dev/null differ diff --git a/backend/perks/__init__.py b/backend/perks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/perks/admin.py b/backend/perks/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/backend/perks/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/backend/perks/apps.py b/backend/perks/apps.py new file mode 100644 index 0000000..bdb66a5 --- /dev/null +++ b/backend/perks/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class PerksConfig(AppConfig): + name = 'perks' diff --git a/backend/perks/migrations/__init__.py b/backend/perks/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/perks/models.py b/backend/perks/models.py new file mode 100644 index 0000000..d837a68 --- /dev/null +++ b/backend/perks/models.py @@ -0,0 +1,6 @@ +from django.db import models + + +class Perk(models.Model): + pass + diff --git a/backend/perks/tests.py b/backend/perks/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/backend/perks/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/perks/urls.py b/backend/perks/urls.py new file mode 100644 index 0000000..6d045a1 --- /dev/null +++ b/backend/perks/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from perks import views + +urlpatterns = [ + path('trees', views.ListTrees.as_view()), + path('trees/', views.ListPerks.as_view()), +] + diff --git a/backend/perks/views.py b/backend/perks/views.py new file mode 100644 index 0000000..b9650fa --- /dev/null +++ b/backend/perks/views.py @@ -0,0 +1,40 @@ +import json + +from os import listdir +from os.path import isfile, join +from rest_framework.views import APIView +from rest_framework.response import Response +from rest_framework import authentication, permissions + + +PERKS_DIR = '../static/perks' + + +def get_tree_list(): + return sorted([file for file in listdir(PERKS_DIR) if isfile(join(PERKS_DIR, file))]) + + +class ListTrees(APIView): + """ + View to list all perk trees + """ + authentication_classes = (authentication.TokenAuthentication,) + # permission_classes = (permissions.IsAuthenticated,) + + def get(self, request, format=None): + return Response([tree[:-5] for tree in get_tree_list()]) + + +class ListPerks(APIView): + """ + View to list all perks in a tree + """ + authentication_classes = (authentication.TokenAuthentication,) + # permission_classes = (permissions.IsAuthenticated,) + + def get(self, request, tree, format=None): + print(request.user) + filename = get_tree_list()[tree] + with open(f'{PERKS_DIR}/{filename}', 'r') as f: + return Response(json.load(f)) + diff --git a/backend/perktree/settings.py b/backend/perktree/settings.py index 832ce16..c050455 100644 --- a/backend/perktree/settings.py +++ b/backend/perktree/settings.py @@ -120,7 +120,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.1/howto/static-files/ -STATIC_URL = '/static/' +STATIC_URL = '/django-static/' REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', diff --git a/backend/perktree/urls.py b/backend/perktree/urls.py index 6cc3cb7..12a7ed6 100644 --- a/backend/perktree/urls.py +++ b/backend/perktree/urls.py @@ -22,14 +22,13 @@ from rest_framework_simplejwt.views import ( TokenVerifyView, ) -# Wire up our API using automatic URL routing. -# Additionally, we include login URLs for the browsable API. urlpatterns = [ path('api/', include([ path('admin/', admin.site.urls), path('token/', TokenObtainPairView.as_view(), name='token_obtain_pair'), path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), path('token/verify/', TokenVerifyView.as_view(), name='token_verify'), + path('', include('perks.urls')) ])) ] diff --git a/frontend/package.json b/frontend/package.json index 7193303..ce70598 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,9 +15,11 @@ "roboto-fontface": "*", "vue": "^2.6.6", "vue-router": "^3.0.2", - "vuetify": "^1.5.5" + "vuetify": "^1.5.5", + "vuex": "^3.1.0" }, "devDependencies": { + "@fortawesome/fontawesome-free": "^5.8.1", "@vue/cli-plugin-eslint": "^3.5.0", "@vue/cli-service": "^3.5.0", "@vue/eslint-config-standard": "^4.0.0", diff --git a/frontend/public/index.html b/frontend/public/index.html index cdcf700..36e1e77 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -5,7 +5,7 @@ - perktree + Perktree