Skip to content

Commit

Permalink
Clean & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
olzhasar-reef committed May 3, 2024
1 parent dd0c33f commit 2776c35
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 44 deletions.
3 changes: 0 additions & 3 deletions app/envs/prod/gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
bind = "0.0.0.0:8000"
wsgi_app = "bittensor_panel.wsgi:application"
access_logfile = "-"



3 changes: 0 additions & 3 deletions app/src/bittensor_panel/asgi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import os


from django.core.asgi import get_asgi_application



os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bittensor_panel.settings")
application = get_asgi_application()
5 changes: 4 additions & 1 deletion app/src/bittensor_panel/celery.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import logging
import os

from celery import Celeryfrom django.conf import settings
from celery import Celery
from celery.signals import setup_logging
from django.conf import settings
from django_structlog.celery.steps import DjangoStructLogInitStep

from .settings import configure_structlog

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bittensor_panel.settings")
Expand Down
1 change: 0 additions & 1 deletion app/src/bittensor_panel/core/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
os.environ["DEBUG_TOOLBAR"] = "False"

from bittensor_panel.settings import * # noqa: E402,F403

2 changes: 1 addition & 1 deletion app/src/bittensor_panel/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def wrapped(*args, **kwargs):
SECURE_SSL_REDIRECT = False

CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend"
CONSTANCE_CONFIG = {
CONSTANCE_CONFIG: dict[str, tuple[str, str, str]] = {
# "PARAMETER": (default-value, "Help text", type),
}

Expand Down
1 change: 0 additions & 1 deletion app/src/bittensor_panel/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.contrib.admin.sites import site
from django.urls import include, path


urlpatterns = [
path("admin/", site.urls),
path("", include("django.contrib.auth.urls")),
Expand Down
4 changes: 2 additions & 2 deletions app/src/bittensor_panel/users/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class UsersConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'bittensor_panel.users'
default_auto_field = "django.db.models.BigAutoField"
name = "bittensor_panel.users"
92 changes: 71 additions & 21 deletions app/src/bittensor_panel/users/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,93 @@

import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
("auth", "0012_alter_user_first_name_max_length"),
]

operations = [
migrations.CreateModel(
name='User',
name="User",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("password", models.CharField(max_length=128, verbose_name="password")),
("last_login", models.DateTimeField(blank=True, null=True, verbose_name="last login")),
(
"is_superuser",
models.BooleanField(
default=False,
help_text="Designates that this user has all permissions without explicitly assigning them.",
verbose_name="superuser status",
),
),
(
"username",
models.CharField(
error_messages={"unique": "A user with that username already exists."},
help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
max_length=150,
unique=True,
validators=[django.contrib.auth.validators.UnicodeUsernameValidator()],
verbose_name="username",
),
),
("first_name", models.CharField(blank=True, max_length=150, verbose_name="first name")),
("last_name", models.CharField(blank=True, max_length=150, verbose_name="last name")),
("email", models.EmailField(blank=True, max_length=254, verbose_name="email address")),
(
"is_staff",
models.BooleanField(
default=False,
help_text="Designates whether the user can log into this admin site.",
verbose_name="staff status",
),
),
(
"is_active",
models.BooleanField(
default=True,
help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
verbose_name="active",
),
),
("date_joined", models.DateTimeField(default=django.utils.timezone.now, verbose_name="date joined")),
(
"groups",
models.ManyToManyField(
blank=True,
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
related_name="user_set",
related_query_name="user",
to="auth.group",
verbose_name="groups",
),
),
(
"user_permissions",
models.ManyToManyField(
blank=True,
help_text="Specific permissions for this user.",
related_name="user_set",
related_query_name="user",
to="auth.permission",
verbose_name="user permissions",
),
),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
'abstract': False,
"verbose_name": "user",
"verbose_name_plural": "users",
"abstract": False,
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
("objects", django.contrib.auth.models.UserManager()),
],
),
]
3 changes: 0 additions & 3 deletions app/src/bittensor_panel/users/tests.py

This file was deleted.

3 changes: 0 additions & 3 deletions app/src/bittensor_panel/users/views.py

This file was deleted.

7 changes: 2 additions & 5 deletions bin/emailhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ def send(self, addr_from, addr_to, subject, message, files=tuple()):
with open(file, "rb") as stream:
part.set_payload(stream.read())
encoders.encode_base64(part)
part.add_header(
"Content-Disposition",
'attachment; filename="%s"' % os.path.basename(file),
)
part.add_header("Content-Disposition", f'attachment; filename="{os.path.basename(file)}"')
msg.attach(part)

s = smtplib.SMTP(self.server, self.port)
Expand Down Expand Up @@ -86,7 +83,7 @@ def parse_arguments():
sys.exit(2)

try:
email_creds = urlsplit("//%s" % email_creds)
email_creds = urlsplit(f"//{email_creds}")
if not all([email_creds.username, email_creds.hostname, email_creds.port]):
raise ValueError
except ValueError:
Expand Down

0 comments on commit 2776c35

Please sign in to comment.