Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infra: format with ruff #2540

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ test: .state/db-initialized

docker_shell: .state/db-initialized
docker-compose run --rm web /bin/bash

fmt: Dockerfile dev-requirements.txt base-requirements.txt
docker-compose run --rm web ruff format .
3 changes: 1 addition & 2 deletions banners/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@


class BannersAppConfig(AppConfig):

name = 'banners'
name = "banners"
17 changes: 4 additions & 13 deletions banners/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = []
Expand All @@ -31,27 +30,19 @@ class Migration(migrations.Migration):
),
(
"message",
models.CharField(
help_text="Message to display in the banner", max_length=2048
),
models.CharField(help_text="Message to display in the banner", max_length=2048),
),
(
"link",
models.CharField(
help_text="Link the button will go to", max_length=1024
),
models.CharField(help_text="Link the button will go to", max_length=1024),
),
(
"active",
models.BooleanField(
default=False, help_text="Make the banner active on the site"
),
models.BooleanField(default=False, help_text="Make the banner active on the site"),
),
(
"psf_pages_only",
models.BooleanField(
default=True, help_text="Display the banner on /psf pages only"
),
models.BooleanField(default=True, help_text="Display the banner on /psf pages only"),
),
],
)
Expand Down
17 changes: 4 additions & 13 deletions banners/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,8 @@


class Banner(models.Model):

title = models.CharField(
max_length=1024, help_text="Text to display in the banner's button"
)
message = models.CharField(
max_length=2048, help_text="Message to display in the banner"
)
title = models.CharField(max_length=1024, help_text="Text to display in the banner's button")
message = models.CharField(max_length=2048, help_text="Message to display in the banner")
link = models.CharField(max_length=1024, help_text="Link the button will go to")
active = models.BooleanField(
null=False, default=False, help_text="Make the banner active on the site"
)
psf_pages_only = models.BooleanField(
null=False, default=True, help_text="Display the banner on /psf pages only"
)
active = models.BooleanField(null=False, default=False, help_text="Make the banner active on the site")
psf_pages_only = models.BooleanField(null=False, default=True, help_text="Display the banner on /psf pages only")
18 changes: 8 additions & 10 deletions blogs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@

@admin.register(BlogEntry)
class BlogEntryAdmin(admin.ModelAdmin):
list_display = ['title', 'pub_date']
date_hierarchy = 'pub_date'
actions = ['sync_new_entries']
list_display = ["title", "pub_date"]
date_hierarchy = "pub_date"
actions = ["sync_new_entries"]

@admin.action(
description="Sync new blog entries"
)
@admin.action(description="Sync new blog entries")
def sync_new_entries(self, request, queryset):
call_command('update_blogs')
call_command("update_blogs")
self.message_user(request, "Blog entries updated.")



@admin.register(FeedAggregate)
class FeedAggregateAdmin(admin.ModelAdmin):
list_display = ['name', 'slug', 'description']
prepopulated_fields = {'slug': ('name',)}
list_display = ["name", "slug", "description"]
prepopulated_fields = {"slug": ("name",)}


admin.site.register(Feed)
3 changes: 1 addition & 2 deletions blogs/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@


class BlogsAppConfig(AppConfig):

name = 'blogs'
name = "blogs"
10 changes: 5 additions & 5 deletions blogs/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def initial_data():
feed, _ = Feed.objects.get_or_create(
id=1,
defaults={
'name': 'Python Insider',
'website_url': settings.PYTHON_BLOG_URL,
'feed_url': settings.PYTHON_BLOG_FEED_URL,
}
"name": "Python Insider",
"website_url": settings.PYTHON_BLOG_URL,
"feed_url": settings.PYTHON_BLOG_FEED_URL,
},
)
return {
'feeds': [feed],
"feeds": [feed],
}
8 changes: 5 additions & 3 deletions blogs/management/commands/update_blogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@


class Command(BaseCommand):
""" Update blog entries and related blog feed data """
"""Update blog entries and related blog feed data"""

def handle(self, **options):
for feed in Feed.objects.all():
entries = get_all_entries(feed.feed_url)

for entry in entries:
url = entry.pop('url')
url = entry.pop("url")
BlogEntry.objects.update_or_create(
feed=feed, url=url, defaults=entry,
feed=feed,
url=url,
defaults=entry,
)

feed.last_import = now()
Expand Down
184 changes: 120 additions & 64 deletions blogs/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,114 +4,170 @@


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='BlogEntry',
name="BlogEntry",
fields=[
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200)),
('summary', models.TextField(blank=True)),
('pub_date', models.DateTimeField()),
('url', models.URLField(verbose_name='URL')),
("id", models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name="ID")),
("title", models.CharField(max_length=200)),
("summary", models.TextField(blank=True)),
("pub_date", models.DateTimeField()),
("url", models.URLField(verbose_name="URL")),
],
options={
'verbose_name': 'Blog Entry',
'verbose_name_plural': 'Blog Entries',
'get_latest_by': 'pub_date',
"verbose_name": "Blog Entry",
"verbose_name_plural": "Blog Entries",
"get_latest_by": "pub_date",
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Contributor',
name="Contributor",
fields=[
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(db_index=True, default=django.utils.timezone.now, blank=True)),
('updated', models.DateTimeField(default=django.utils.timezone.now, blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_contributor_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_contributor_modified', blank=True, on_delete=models.CASCADE)),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='blog_contributor', on_delete=models.CASCADE)),
("id", models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name="ID")),
("created", models.DateTimeField(db_index=True, default=django.utils.timezone.now, blank=True)),
("updated", models.DateTimeField(default=django.utils.timezone.now, blank=True)),
(
"creator",
models.ForeignKey(
null=True,
to=settings.AUTH_USER_MODEL,
related_name="blogs_contributor_creator",
blank=True,
on_delete=models.CASCADE,
),
),
(
"last_modified_by",
models.ForeignKey(
null=True,
to=settings.AUTH_USER_MODEL,
related_name="blogs_contributor_modified",
blank=True,
on_delete=models.CASCADE,
),
),
(
"user",
models.ForeignKey(
to=settings.AUTH_USER_MODEL, related_name="blog_contributor", on_delete=models.CASCADE
),
),
],
options={
'verbose_name': 'Contributor',
'verbose_name_plural': 'Contributors',
'ordering': ('user__last_name', 'user__first_name'),
"verbose_name": "Contributor",
"verbose_name_plural": "Contributors",
"ordering": ("user__last_name", "user__first_name"),
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Feed',
name="Feed",
fields=[
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('website_url', models.URLField()),
('feed_url', models.URLField()),
('last_import', models.DateTimeField(null=True, blank=True)),
("id", models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name="ID")),
("name", models.CharField(max_length=200)),
("website_url", models.URLField()),
("feed_url", models.URLField()),
("last_import", models.DateTimeField(null=True, blank=True)),
],
options={
},
options={},
bases=(models.Model,),
),
migrations.CreateModel(
name='FeedAggregate',
name="FeedAggregate",
fields=[
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('slug', models.SlugField(unique=True)),
('description', models.TextField(help_text='Where this appears on the site')),
('feeds', models.ManyToManyField(to='blogs.Feed')),
("id", models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name="ID")),
("name", models.CharField(max_length=200)),
("slug", models.SlugField(unique=True)),
("description", models.TextField(help_text="Where this appears on the site")),
("feeds", models.ManyToManyField(to="blogs.Feed")),
],
options={
},
options={},
bases=(models.Model,),
),
migrations.CreateModel(
name='RelatedBlog',
name="RelatedBlog",
fields=[
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(db_index=True, default=django.utils.timezone.now, blank=True)),
('updated', models.DateTimeField(default=django.utils.timezone.now, blank=True)),
('name', models.CharField(help_text='Internal Name', max_length=100)),
('feed_url', models.URLField(verbose_name='Feed URL')),
('blog_url', models.URLField(verbose_name='Blog URL')),
('blog_name', models.CharField(help_text='Displayed Name', max_length=200)),
('last_entry_published', models.DateTimeField(db_index=True)),
('last_entry_title', models.CharField(max_length=500)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_relatedblog_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_relatedblog_modified', blank=True, on_delete=models.CASCADE)),
("id", models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name="ID")),
("created", models.DateTimeField(db_index=True, default=django.utils.timezone.now, blank=True)),
("updated", models.DateTimeField(default=django.utils.timezone.now, blank=True)),
("name", models.CharField(help_text="Internal Name", max_length=100)),
("feed_url", models.URLField(verbose_name="Feed URL")),
("blog_url", models.URLField(verbose_name="Blog URL")),
("blog_name", models.CharField(help_text="Displayed Name", max_length=200)),
("last_entry_published", models.DateTimeField(db_index=True)),
("last_entry_title", models.CharField(max_length=500)),
(
"creator",
models.ForeignKey(
null=True,
to=settings.AUTH_USER_MODEL,
related_name="blogs_relatedblog_creator",
blank=True,
on_delete=models.CASCADE,
),
),
(
"last_modified_by",
models.ForeignKey(
null=True,
to=settings.AUTH_USER_MODEL,
related_name="blogs_relatedblog_modified",
blank=True,
on_delete=models.CASCADE,
),
),
],
options={
'verbose_name': 'Related Blog',
'verbose_name_plural': 'Related Blogs',
"verbose_name": "Related Blog",
"verbose_name_plural": "Related Blogs",
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Translation',
name="Translation",
fields=[
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(db_index=True, default=django.utils.timezone.now, blank=True)),
('updated', models.DateTimeField(default=django.utils.timezone.now, blank=True)),
('name', models.CharField(max_length=100)),
('url', models.URLField(verbose_name='URL')),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_translation_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_translation_modified', blank=True, on_delete=models.CASCADE)),
("id", models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name="ID")),
("created", models.DateTimeField(db_index=True, default=django.utils.timezone.now, blank=True)),
("updated", models.DateTimeField(default=django.utils.timezone.now, blank=True)),
("name", models.CharField(max_length=100)),
("url", models.URLField(verbose_name="URL")),
(
"creator",
models.ForeignKey(
null=True,
to=settings.AUTH_USER_MODEL,
related_name="blogs_translation_creator",
blank=True,
on_delete=models.CASCADE,
),
),
(
"last_modified_by",
models.ForeignKey(
null=True,
to=settings.AUTH_USER_MODEL,
related_name="blogs_translation_modified",
blank=True,
on_delete=models.CASCADE,
),
),
],
options={
'verbose_name': 'Translation',
'verbose_name_plural': 'Translations',
'ordering': ('name',),
"verbose_name": "Translation",
"verbose_name_plural": "Translations",
"ordering": ("name",),
},
bases=(models.Model,),
),
migrations.AddField(
model_name='blogentry',
name='feed',
field=models.ForeignKey(to='blogs.Feed', on_delete=models.CASCADE),
model_name="blogentry",
name="feed",
field=models.ForeignKey(to="blogs.Feed", on_delete=models.CASCADE),
preserve_default=True,
),
]
Loading