Skip to content

Commit

Permalink
add formatting file, apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloodmallet committed Feb 22, 2019
1 parent dd344d9 commit 608e25a
Show file tree
Hide file tree
Showing 11 changed files with 414 additions and 407 deletions.
8 changes: 8 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[style]
based_on_style = chromium
indent_width = 4
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = true
DEDENT_CLOSING_BRACKETS = true
JOIN_MULTIPLE_LINES = true
CONTINUATION_INDENT_WIDTH = 4
COLUMN_LIMIT = 119
29 changes: 13 additions & 16 deletions bloodmallet/bloodmallet/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/


# Application definition

INSTALLED_APPS = [
Expand All @@ -28,7 +27,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites', # required by django-allauth
'django.contrib.sites', # required by django-allauth
'allauth',
'allauth.account',
'allauth.socialaccount',
Expand Down Expand Up @@ -56,23 +55,24 @@
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'general_website', 'templates', 'allauth') # allauth templates
os.path.join(BASE_DIR, 'general_website', 'templates', 'allauth') # allauth templates
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
'OPTIONS':
{
'context_processors':
[
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'bloodmallet.wsgi.application'


# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators

Expand All @@ -91,7 +91,6 @@
},
]


# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/

Expand All @@ -105,7 +104,6 @@

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/

Expand All @@ -120,7 +118,6 @@
'sass_processor.finders.CssFinder',
]


# TODO: Check https://django-allauth.readthedocs.io/en/latest/faq.html for patreon connection
# django-allauth
AUTHENTICATION_BACKENDS = (
Expand All @@ -134,7 +131,7 @@
SITE_ID = 1

# we can either use crispy or bootstrap4
CRISPY_TEMPLATE_PACK = 'bootstrap4' # automatic bootstrap form frontend generator
CRISPY_TEMPLATE_PACK = 'bootstrap4' # automatic bootstrap form frontend generator

# from where is this?
LOGIN_URL = 'login'
25 changes: 12 additions & 13 deletions bloodmallet/bloodmallet/settings/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.join(BASE_DIR, '..')


ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
Expand Down Expand Up @@ -63,25 +62,25 @@

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'


# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
import pymysql
pymysql.install_as_MySQLdb()
from .secrets import DB_HOST, DB_NAME, DB_USER, DB_PASSWORD

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '127.0.0.1',
'PORT': '3306',
'NAME': DB_NAME,
'USER': DB_USER,
'PASSWORD': DB_PASSWORD,
'OPTIONS': {
'charset': 'utf8mb4'
},
}
'default':
{
'ENGINE': 'django.db.backends.mysql',
'HOST': '127.0.0.1',
'PORT': '3306',
'NAME': DB_NAME,
'USER': DB_USER,
'PASSWORD': DB_PASSWORD,
'OPTIONS': {
'charset': 'utf8mb4'
},
}
}

# used to serve files from this path in non-debug production
Expand Down
27 changes: 12 additions & 15 deletions bloodmallet/bloodmallet/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = [
'*'
]
ALLOWED_HOSTS = ['*']

# logging
LOGGING = {
Expand Down Expand Up @@ -47,25 +45,24 @@
},
}


# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
import pymysql
pymysql.install_as_MySQLdb()
from .secrets import DB_HOST, DB_NAME, DB_USER, DB_PASSWORD

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '/cloudsql/{}'.format(DB_HOST),
'NAME': DB_NAME,
'USER': DB_USER,
'PASSWORD': DB_PASSWORD,
'OPTIONS': {
'charset': 'utf8mb4'
},

}
'default':
{
'ENGINE': 'django.db.backends.mysql',
'HOST': '/cloudsql/{}'.format(DB_HOST),
'NAME': DB_NAME,
'USER': DB_USER,
'PASSWORD': DB_PASSWORD,
'OPTIONS': {
'charset': 'utf8mb4'
},
}
}

# used to serve files from this path in non-debug production
Expand Down
11 changes: 8 additions & 3 deletions bloodmallet/general_website/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ class SignUpForm(UserCreationForm):

class Meta:
model = User
fields = ('username', 'email', 'password1', 'password2', )
fields = (
'username',
'email',
'password1',
'password2',
)


class UserLoginForm(AuthenticationForm):
Expand All @@ -42,13 +47,13 @@ class UserUpdateForm(PasswordChangeForm):
"""
pass


class ProfileUpdateForm(forms.ModelForm):

class Meta:
model = Profile
fields = ('bloodyfiller', )
fields = ('bloodyfiller',)

help_texts = {
'bloodyfiller': "Allow others to see your short message in the title. \"Bloody( [Bloodyfiller] )\"",
}

18 changes: 14 additions & 4 deletions bloodmallet/general_website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# Create your models here.


@receiver([pre_social_login, social_account_updated])
def update_pledge_level(sender, sociallogin, **kwargs):
"""Checks kwargs for pledge level in account data.
Expand All @@ -23,12 +24,14 @@ def update_pledge_level(sender, sociallogin, **kwargs):
print(sender)
print(sociallogin)
try:
print(sociallogin.account) # read social allauth models.py
print(sociallogin.account) # read social allauth models.py
except Exception:
print("No social.account could be found yet. Probably linking in progress.")


#https://stackoverflow.com/questions/40684838/django-django-allauth-save-extra-data-from-social-login-in-signal


@receiver(user_logged_in)
def update_user_information(sender, request, user, **kwargs):
"""Login triggers a check for the patreon level.
Expand All @@ -45,14 +48,18 @@ def update_user_information(sender, request, user, **kwargs):
print(request)
print(user)
print(user.email)


# https://docs.patreon.com/#fetching-a-patron-39-s-profile-info


class Faction(models.Model):
"""Collection of Wow Factions...two, duh.
"""

name = models.CharField(max_length=30)


class Teleporter(models.Model):
"""Collection of fixed position Teleporters.
"""
Expand All @@ -74,6 +81,7 @@ def coordinates(self) -> Tuple[float, float]:

return (self.x, self.y)


class Profile(models.Model):
"""Extension of the standard Django User
Expand All @@ -84,10 +92,12 @@ class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
bloodyfiller = models.CharField(max_length=10, null=True, blank=True)


@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
Profile.objects.create(user=instance)
Profile.objects.create(user=instance) # pylint: disable=no-member


@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
Expand All @@ -105,5 +115,5 @@ def emergency_create_user_profile(sender, request, user, **kwargs):
"""
try:
user.profile
except Exception as e:
Profile.objects.create(user=user)
except Exception:
Profile.objects.create(user=user) # pylint: disable=no-member
Original file line number Diff line number Diff line change
Expand Up @@ -6727,5 +6727,3 @@ select::-ms-expand {

.highcharts-tooltip {
z-index: 400; }

/*# sourceMappingURL=base.css.map */
Expand Down
1 change: 0 additions & 1 deletion bloodmallet/general_website/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
path('settings/profile', views.profile, name='profile'),
path('settings/change_password', views.change_password, name='change_password'),


# allauth account actions
path('accounts/', include('allauth.urls')),
path('settings/connections', ConnectionsView.as_view(), name='account_connections'),
Expand Down
5 changes: 1 addition & 4 deletions bloodmallet/general_website/views/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ def profile(request):
user_form = UserUpdateForm(user=request.user)
profile_form = ProfileUpdateForm(instance=request.user.profile)

content = {
'user_form': user_form,
'profile_form': profile_form
}
content = {'user_form': user_form, 'profile_form': profile_form}

return render(request, 'general_website/profile.html', content)

Expand Down
9 changes: 2 additions & 7 deletions bloodmallet/general_website/views/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@
logger = logging.getLogger(__name__)


def error(request, code: int=404, message: str="Page not found"):
error = {
'error': {
'code': code,
'text': message
}
}
def error(request, code: int = 404, message: str = "Page not found"):
error = {'error': {'code': code, 'text': message}}
return render(request, 'general_website/error.html', error, status=code)


Expand Down
Loading

0 comments on commit 608e25a

Please sign in to comment.