Skip to content

Commit

Permalink
run pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-nork committed Jul 10, 2023
1 parent 38ff442 commit bd96ad8
Show file tree
Hide file tree
Showing 27 changed files with 84 additions and 26,375 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/django-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ jobs:
cd chirps; python manage.py test
- name: Run Linting
run: |
isort --check-only --diff .
pre-commit run -a
pylint --load-plugins pylint_django --django-settings-module="chirps.settings" $(find . -name "*.py" | xargs)
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ cython_debug/
.vscode/launch.json

chirps/erl_crash.dump
*.dump
*.dump
1 change: 1 addition & 0 deletions chirps/account/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ProfileInline(admin.StackedInline):

class UserAdmin(BaseUserAdmin):
"""Define a new User admin."""

inlines = [ProfileInline]


Expand Down
2 changes: 1 addition & 1 deletion chirps/account/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Configures the account app."""""
"""Configures the account app."""
from django.apps import AppConfig


Expand Down
3 changes: 3 additions & 0 deletions chirps/account/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ def clean_openai_key(self):

class Meta:
"""Meta class for ProfileForm."""

model = Profile
fields = ['openai_key']

widgets = {'openai_key': forms.PasswordInput(attrs={'class': 'form-control'})}


class LoginForm(forms.Form):
"""Form for logging in."""

username = forms.CharField(max_length=256)
password = forms.CharField(max_length=256, widget=forms.PasswordInput)


class SignupForm(forms.Form):
"""Form for signing up."""

Expand Down
11 changes: 4 additions & 7 deletions chirps/account/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ def test_new_account_signup(self):
email = '[email protected]'

# Create a new account
response = self.client.post(reverse('signup'), {
'username': username,
'email': email,
'password1': password,
'password2': password
})
response = self.client.post(
reverse('signup'), {'username': username, 'email': email, 'password1': password, 'password2': password}
)
self.assertRedirects(response, '/', 302)

# Logout (since the account creation )
Expand All @@ -47,6 +44,6 @@ def test_new_account_signup(self):
{
'username': username,
'password': password,
}
},
)
self.assertRedirects(response, '/', status_code=302)
2 changes: 1 addition & 1 deletion chirps/account/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
'password_reset/',
auth_views.PasswordResetView.as_view(template_name='account/password_reset.html'),
name='password_reset',
)
),
]
12 changes: 6 additions & 6 deletions chirps/account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def profile(request):

return render(request, 'account/profile.html', {'form': form})


def signup(request):
"""Render the signup page and handle posts."""
if request.method == 'POST':
Expand All @@ -48,9 +49,7 @@ def signup(request):
if has_error is False:
# Create the user:
user = User.objects.create_user(
form.cleaned_data['username'],
form.cleaned_data['email'],
form.cleaned_data['password1']
form.cleaned_data['username'], form.cleaned_data['email'], form.cleaned_data['password1']
)
user.save()

Expand All @@ -68,6 +67,7 @@ def signup(request):

return render(request, 'account/signup.html', {'form': form})


def login_view(request):
"""Render the login page."""

Expand All @@ -78,9 +78,9 @@ def login_view(request):
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
user = authenticate(request=request,
username=form.cleaned_data['username'],
password=form.cleaned_data['password'])
user = authenticate(
request=request, username=form.cleaned_data['username'], password=form.cleaned_data['password']
)
if user:
login(request, user)
return redirect('/')
Expand Down
5 changes: 2 additions & 3 deletions chirps/base_app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

class InstallForm(forms.Form):
"""Form to render the new installation page."""

superuser_username = forms.CharField(label='Superuser Username', max_length=100)
superuser_email = forms.EmailField(label='Superuser Email', max_length=100)
superuser_password = forms.CharField(label='Superuser Password', max_length=100, widget=forms.PasswordInput)
superuser_password_confirm = forms.CharField(
label='Superuser Password (Confirm)',
max_length=100,
widget=forms.PasswordInput
label='Superuser Password (Confirm)', max_length=100, widget=forms.PasswordInput
)
1 change: 1 addition & 0 deletions chirps/base_app/management/commands/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class Command(BaseCommand):
"""Manage a local celery installation with this command."""

help = 'Interact with the local celery broker'

def add_arguments(self, parser):
Expand Down
1 change: 1 addition & 0 deletions chirps/base_app/management/commands/initialize_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class Command(BaseCommand):
"""Initialize the app by running multiple management commands."""

help = 'Initialize the app by running multiple management commands'

def handle(self, *args, **options):
Expand Down
1 change: 1 addition & 0 deletions chirps/base_app/management/commands/rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class Command(BaseCommand):
"""Management command for interacting with rabbitmq."""

help = 'Interact with the local rabbitmq development server'

def add_arguments(self, parser):
Expand Down
1 change: 1 addition & 0 deletions chirps/base_app/management/commands/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class Command(BaseCommand):
"""Management command for interacting with redis."""

help = 'Interact with the local redis development server'

def add_arguments(self, parser):
Expand Down
1 change: 1 addition & 0 deletions chirps/base_app/management/commands/start_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class Command(BaseCommand):
"""Initialize the app by running multiple management commands."""

help = 'Initialize the app by running multiple management commands'

def handle(self, *args, **options):
Expand Down
2 changes: 1 addition & 1 deletion chirps/base_app/static/css/bootstrap.min.css

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions chirps/base_app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@

from . import views

urlpatterns = [
path('', views.index, name='index'),
path('install', views.install, name='install')
]
urlpatterns = [path('', views.index, name='index'), path('install', views.install, name='install')]
3 changes: 2 additions & 1 deletion chirps/base_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def index(request):
"""Render the index page."""
return render(request, 'dashboard/index.html', {})


def install(request):
"""Render the install page."""

Expand Down Expand Up @@ -42,7 +43,7 @@ def install(request):
user = User.objects.create_superuser(
form.cleaned_data['superuser_username'],
form.cleaned_data['superuser_email'],
form.cleaned_data['superuser_password']
form.cleaned_data['superuser_password'],
)

# Create the user profile
Expand Down
28 changes: 14 additions & 14 deletions chirps/chirps/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,28 +148,28 @@

# FERNET SETTINGS
if os.getenv('FERNET_KEY') is None:
raise Exception('FERNET_KEY environment variable is not set') # pylint: disable=broad-exception-raised
raise Exception('FERNET_KEY environment variable is not set') # pylint: disable=broad-exception-raised

FERNET_KEY = os.getenv('FERNET_KEY')

# LOGGING Configuration Options
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"class": "logging.StreamHandler",
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
"root": {
"handlers": ["console"],
"level": "WARNING",
'root': {
'handlers': ['console'],
'level': 'WARNING',
},
"loggers": {
"django": {
"handlers": ["console"],
"level": os.getenv("DJANGO_LOG_LEVEL", "INFO"),
"propagate": False,
'loggers': {
'django': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
'propagate': False,
},
},
}
Loading

0 comments on commit bd96ad8

Please sign in to comment.