Make changes to configure for running on ec2 instance

This commit is contained in:
Geeksbot 2019-12-12 07:45:41 +00:00
parent 0caeba5cbd
commit 5fef17104d
33 changed files with 70 additions and 70 deletions

4
.gitignore vendored
View File

@ -165,7 +165,7 @@ typings/
# Provided default Pycharm Run/Debug Configurations should be tracked by git
# In case of local modifications made by Pycharm, use update-index command
# for each changed file, like this:
# git update-index --assume-unchanged .idea/geeksbot_web.iml
# git update-index --assume-unchanged .idea/iml
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
@ -325,7 +325,7 @@ tags
### Project template
geeksbot_web/media/
media/
.pytest_cache/

View File

@ -1,4 +1,4 @@
FROM python:3.7-alpine AS geeksbot-web
FROM python:3.8-alpine AS geeksbot-web
ENV DEBIAN_FRONTEND noninteractive
ENV PYTHONUNBUFFERED 1
@ -53,7 +53,7 @@ RUN rm -rf /tmp/*
RUN mkdir -p /tmp/logs/nginx
RUN mkdir -p /tmp/logs/geeksbot
RUN mkdir -p /code/geeksbot_web
COPY geeksbot_web/* /code/geeksbot_web/
COPY ./* /code/
WORKDIR /code/geeksbot_web

View File

@ -3,5 +3,5 @@ from django.utils.translation import gettext_lazy as _
class ChannelsConfig(AppConfig):
name = 'geeksbot_web.channels'
name = 'channels'
verbose_name = _("Channels")

View File

@ -2,7 +2,7 @@ from django.db import models
from django.core.exceptions import ObjectDoesNotExist
from rest_framework import status
from geeksbot_web.guilds.models import Guild
from guilds.models import Guild
from .utils import create_error_response
from .utils import create_success_response

View File

@ -3,7 +3,7 @@ from rest_framework import status
from rest_framework.permissions import IsAuthenticated
from django.core.exceptions import ObjectDoesNotExist
from geeksbot_web.utils.api_utils import PaginatedAPIView
from utils.api_utils import PaginatedAPIView
from .models import Channel
from .utils import create_error_response
from .utils import create_success_response

View File

@ -7,16 +7,16 @@ import sys
ROOT_DIR = (
environ.Path(__file__) - 3
) # (geeksbot_web/config/settings/base.py - 3 = geeksbot_web/)
) # (config/settings/base.py - 3 = )
APPS_DIR = ROOT_DIR
CODE_DIR = ( environ.Path(__file__) - 4 )
sys.path.append(str(CODE_DIR))
#CODE_DIR = ( environ.Path(__file__) - 4 )
#sys.path.append(str(CODE_DIR))
print(sys.path)
env = environ.Env()
READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=True)
READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=False)
if READ_DOT_ENV_FILE:
# OS environment variables take precedence over variables from .env
env.read_env(str(CODE_DIR.path(".env")))
@ -89,12 +89,12 @@ THIRD_PARTY_APPS = [
]
LOCAL_APPS = [
"geeksbot_web.users.apps.UsersConfig",
"geeksbot_web.guilds.apps.GuildsConfig",
"geeksbot_web.dmessages.apps.MessagesConfig",
"geeksbot_web.patreon.apps.PatreonConfig",
"geeksbot_web.rcon.apps.RconConfig",
"geeksbot_web.channels.apps.ChannelsConfig",
"users.apps.UsersConfig",
"guilds.apps.GuildsConfig",
"dmessages.apps.MessagesConfig",
"patreon.apps.PatreonConfig",
"rcon.apps.RconConfig",
"channels.apps.ChannelsConfig",
# Your stuff: custom apps go here
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
@ -103,7 +103,7 @@ INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
# MIGRATIONS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#migration-modules
MIGRATION_MODULES = {"sites": "geeksbot_web.contrib.sites.migrations"}
MIGRATION_MODULES = {"sites": "contrib.sites.migrations"}
# AUTHENTICATION
# ------------------------------------------------------------------------------
@ -276,11 +276,11 @@ ACCOUNT_EMAIL_REQUIRED = False
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_EMAIL_VERIFICATION = "optional"
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_ADAPTER = "geeksbot_web.users.adapters.AccountAdapter"
ACCOUNT_ADAPTER = "users.adapters.AccountAdapter"
# https://django-allauth.readthedocs.io/en/latest/configuration.html
SOCIALACCOUNT_ADAPTER = "geeksbot_web.users.adapters.SocialAccountAdapter"
SOCIALACCOUNT_ADAPTER = "users.adapters.SocialAccountAdapter"
ACCOUNT_FORMS = {
'signup': 'geeksbot_web.users.forms.UserCreateForm',
'signup': 'users.forms.UserCreateForm',
}

View File

@ -13,14 +13,14 @@ urlpatterns = [
# Django Admin, use {% url 'admin:index' %}
path(settings.ADMIN_URL, admin.site.urls),
# User management
path("users/", include("geeksbot_web.users.urls", namespace="users")),
path("users/", include("users.urls", namespace="users")),
path("accounts/", include("allauth.urls")),
# Your stuff: custom urls includes go here
path("api/users/", include("geeksbot_web.users.api_urls", namespace="users_api")),
path("api/guilds/", include("geeksbot_web.guilds.api_urls", namespace="guilds_api")),
path("api/channels/", include("geeksbot_web.channels.api_urls", namespace="channels_api")),
path("api/messages/", include("geeksbot_web.dmessages.api_urls", namespace="messages_api")),
path("api/rcon/", include("geeksbot_web.rcon.api_urls", namespace="rcon_api")),
path("api/users/", include("users.api_urls", namespace="users_api")),
path("api/guilds/", include("guilds.api_urls", namespace="guilds_api")),
path("api/channels/", include("channels.api_urls", namespace="channels_api")),
path("api/messages/", include("dmessages.api_urls", namespace="messages_api")),
path("api/rcon/", include("rcon.api_urls", namespace="rcon_api")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if settings.DEBUG:

View File

@ -19,7 +19,7 @@ import sys
from django.core.wsgi import get_wsgi_application
# This allows easy placement of apps within the interior
# geeksbot_web directory.
# directory.
app_path = os.path.abspath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)
)

View File

@ -2,7 +2,7 @@ import pytest
from django.conf import settings
from django.test import RequestFactory
from geeksbot_web.users.tests.factories import UserFactory
from users.tests.factories import UserFactory
@pytest.fixture(autouse=True)

View File

@ -3,5 +3,5 @@ from django.utils.translation import gettext_lazy as _
class MessagesConfig(AppConfig):
name = 'geeksbot_web.dmessages'
name = 'dmessages'
verbose_name = _("DMessages")

View File

@ -5,10 +5,10 @@ from django.core.exceptions import ObjectDoesNotExist
from django.contrib.postgres.fields import ArrayField
from rest_framework import status
from geeksbot_web.guilds.models import Guild
from geeksbot_web.guilds.models import Role
from geeksbot_web.users.models import User
from geeksbot_web.channels.models import Channel
from guilds.models import Guild
from guilds.models import Role
from users.models import User
from channels.models import Channel
from .utils import create_error_response
from .utils import create_success_response
from .utils import create_request_success_response

View File

@ -13,7 +13,7 @@ from .models import Message
from .models import AdminComment
from .models import AdminRequest
from .models import GuildInfo
from geeksbot_web.utils.api_utils import PaginatedAPIView
from utils.api_utils import PaginatedAPIView
from .utils import create_error_response
from .utils import create_success_response
from .utils import create_request_success_response

View File

@ -1,7 +1,7 @@
from django.contrib import admin
from geeksbot_web.guilds.models import Guild
from geeksbot_web.guilds.models import Role
from guilds.models import Guild
from guilds.models import Role
# Register your models here.
admin.site.register(Guild)

View File

@ -3,5 +3,5 @@ from django.utils.translation import gettext_lazy as _
class GuildsConfig(AppConfig):
name = 'geeksbot_web.guilds'
name = 'guilds'
verbose_name = _("Guilds")

View File

@ -1,7 +1,7 @@
from rest_framework import serializers
from geeksbot_web.guilds.models import Guild
from geeksbot_web.guilds.models import Role
from guilds.models import Guild
from guilds.models import Role
class GuildSerializer(serializers.ModelSerializer):

View File

@ -3,7 +3,7 @@ from rest_framework import status
from rest_framework.permissions import IsAuthenticated
from django.core.exceptions import ObjectDoesNotExist
from geeksbot_web.utils.api_utils import PaginatedAPIView
from utils.api_utils import PaginatedAPIView
from .models import Guild
from .models import Role
from .utils import create_error_response

View File

@ -3,7 +3,7 @@ import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "geeksbot_web.config.settings.local")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
try:
from django.core.management import execute_from_command_line
@ -23,7 +23,7 @@ if __name__ == "__main__":
raise
# This allows easy placement of apps within the interior
# geeksbot_web directory.
# directory.
current_path = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(current_path, "geeksbot_web"))

View File

@ -3,5 +3,5 @@ from django.utils.translation import gettext_lazy as _
class PatreonConfig(AppConfig):
name = 'geeksbot_web.patreon'
name = 'patreon'
verbose_name = _("Patreon")

View File

@ -2,8 +2,8 @@ from django.db import models
from django.core.exceptions import ObjectDoesNotExist
from rest_framework import status
from geeksbot_web.guilds.models import Guild
from geeksbot_web.guilds.models import Role
from guilds.models import Guild
from guilds.models import Role
from .utils import create_error_response
from .utils import create_success_creator_response
from .utils import create_success_tier_response

View File

@ -1,7 +1,7 @@
from rest_framework import serializers
from geeksbot_web.patreon.models import PatreonCreator
from geeksbot_web.patreon.models import PatreonTier
from patreon.models import PatreonCreator
from patreon.models import PatreonTier
class PatreonCreatorSerializer(serializers.ModelSerializer):

View File

@ -3,5 +3,5 @@ from django.utils.translation import gettext_lazy as _
class RconConfig(AppConfig):
name = 'geeksbot_web.rcon'
name = 'rcon'
verbose_name = _("Rcon")

View File

@ -2,10 +2,10 @@ from django.db import models
from django.core.exceptions import ObjectDoesNotExist
from rest_framework import status
from geeksbot_web.guilds.models import Guild
from geeksbot_web.dmessages.models import Message
from geeksbot_web.users.models import User
from geeksbot_web.channels.models import Channel
from guilds.models import Guild
from dmessages.models import Message
from users.models import User
from channels.models import Channel
from .utils import create_error_response
from .utils import create_success_response

View File

@ -1,6 +1,6 @@
from rest_framework import serializers
from geeksbot_web.rcon.models import RconServer
from rcon.models import RconServer
class RconServerSerializer(serializers.ModelSerializer):

View File

@ -8,7 +8,7 @@ from .rcon_lib import arcon
from .models import RconServer
from .utils import create_error_response, create_success_response, create_rcon_response
from geeksbot_web.utils.api_utils import PaginatedAPIView
from utils.api_utils import PaginatedAPIView
from .serializers import RconServerSerializer
# Create your views here.

View File

@ -1,6 +1,6 @@
from django.urls import path
from geeksbot_web.users.views import UsersAPI, UserDetail, UserLogList, UserLogDetail
from users.views import UsersAPI, UserDetail, UserLogList, UserLogDetail
app_name = "users_api"
urlpatterns = [

View File

@ -3,11 +3,11 @@ from django.utils.translation import gettext_lazy as _
class UsersConfig(AppConfig):
name = "geeksbot_web.users"
name = "users"
verbose_name = _("Users")
def ready(self):
try:
import geeksbot_web.users.signals # noqa F401
import users.signals # noqa F401
except ImportError:
pass

View File

@ -12,7 +12,7 @@ from rest_framework.authtoken.models import Token
from django.core.exceptions import ObjectDoesNotExist
from rest_framework import status
from geeksbot_web.guilds.models import Guild
from guilds.models import Guild
from .utils import verify_user_data
from .utils import create_error_response
from .utils import create_log_success_response

View File

@ -1,7 +1,7 @@
from rest_framework import serializers
from geeksbot_web.users.models import User
from geeksbot_web.users.models import UserLog
from users.models import User
from users.models import UserLog
class UserSerializer(serializers.HyperlinkedModelSerializer):

View File

@ -1,7 +1,7 @@
import pytest
from geeksbot_web.users.forms import UserCreationForm
from geeksbot_web.users.tests.factories import UserFactory
from users.forms import UserCreationForm
from users.tests.factories import UserFactory
pytestmark = pytest.mark.django_db

View File

@ -2,7 +2,7 @@ import pytest
from django.conf import settings
from django.test import RequestFactory
from geeksbot_web.users.views import UserRedirectView, UserUpdateView
from users.views import UserRedirectView, UserUpdateView
pytestmark = pytest.mark.django_db

View File

@ -1,6 +1,6 @@
from django.urls import path
from geeksbot_web.users.views import (
from users.views import (
user_redirect_view,
user_update_view,
user_detail_view,

View File

@ -10,12 +10,12 @@ from rest_framework import status
from .models import UserLog
from geeksbot_web.utils.api_utils import PaginatedAPIView
from utils.api_utils import PaginatedAPIView
from .models import User
from .serializers import UserSerializer
from .serializers import UserLogSerializer
from geeksbot_web.utils.permissions import CustomDjangoModelPermissions
from geeksbot_web.utils.permissions import CustomDjangoObjectPermissions
from utils.permissions import CustomDjangoModelPermissions
from utils.permissions import CustomDjangoObjectPermissions
from .utils import create_error_response
from .utils import create_success_response
from .utils import create_log_success_response

View File

@ -13,11 +13,11 @@ server {
error_log /tmp/logs/geeksbot/error.log;
location /static/ {
alias /code/geeksbot_web/staticfiles/;
alias /code/staticfiles/;
}
location /error/ {
alias /code/geeksbot_web/staticfiles/errors/;
alias /code/staticfiles/errors/;
}
location / {