Skip to content

Commit fae7662

Browse files
committed
More updates
1 parent d28265f commit fae7662

File tree

5 files changed

+77
-25
lines changed

5 files changed

+77
-25
lines changed

manage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env python
22
"""Django's command-line utility for administrative tasks."""
3+
34
import os
45
import sys
56

67

78
def main():
89
"""Run administrative tasks."""
9-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
10+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
1011
try:
1112
from django.core.management import execute_from_command_line
1213
except ImportError as exc:
@@ -18,5 +19,5 @@ def main():
1819
execute_from_command_line(sys.argv)
1920

2021

21-
if __name__ == '__main__':
22+
if __name__ == "__main__":
2223
main()

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ ignore = [
4343
"FIX002", # Line contains TODO, consider resolving the issue
4444
"TD002", # Missing author in TODO
4545
"S308", # suspicious-mark-safe-usage
46+
"COM812", # Trailing comma missing
4647
]
4748

4849
[tool.ruff.lint.per-file-ignores]

spf_generator/management/commands/populate_spf_data.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ def handle(self, *args: Any, **options: Any) -> None: # noqa: ANN401, ARG002
153153
"lookup_count": 1,
154154
"priority": 20,
155155
"notes": (
156-
"Covers all Postmark sending servers\n"
157-
"https://postmarkapp.com/guides/spf#2-create-your-spf-record"
156+
"Covers all Postmark sending servers\nhttps://postmarkapp.com/guides/spf#2-create-your-spf-record"
158157
),
159158
},
160159
{
@@ -253,5 +252,5 @@ def handle(self, *args: Any, **options: Any) -> None: # noqa: ANN401, ARG002
253252
)
254253
self.stdout.write(
255254
# pyrefly: ignore [missing-attribute]
256-
self.style.SUCCESS(f'Created provider: {provider_data["name"]}'),
255+
self.style.SUCCESS(f"Created provider: {provider_data['name']}"),
257256
)

spf_generator/migrations/0001_initial.py

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,82 @@
44

55

66
class Migration(migrations.Migration):
7-
87
# pyrefly: ignore [bad-override]
98
initial = True
109

11-
dependencies = [
12-
]
10+
dependencies = []
1311

1412
operations = [
1513
migrations.CreateModel(
16-
name='EmailProvider',
14+
name="EmailProvider",
1715
fields=[
18-
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19-
('name', models.CharField(help_text="Name of the email provider (e.g., 'Google Workspace', 'SendGrid')", max_length=100, unique=True)),
20-
('category', models.CharField(choices=[('EMAIL_HOSTING', 'Email Hosting'), ('TRANSACTIONAL', 'Transactional Email'), ('OTHER', 'Other')], help_text='Category of email provider', max_length=20)),
21-
('description', models.TextField(blank=True, help_text='Public description of the provider')),
22-
('mechanism_type', models.CharField(choices=[('include', 'Include'), ('a', 'A Record'), ('mx', 'MX Record'), ('ip4', 'IPv4'), ('ip6', 'IPv6'), ('exists', 'Exists')], help_text='Type of SPF mechanism used', max_length=10)),
23-
('mechanism_value', models.CharField(help_text="The actual SPF mechanism value (e.g., 'include:_spf.google.com')", max_length=255)),
24-
('lookup_count', models.PositiveSmallIntegerField(default=1, help_text='Number of DNS lookups this mechanism requires')),
25-
('priority', models.PositiveSmallIntegerField(default=100, help_text='Order in which this should appear in combined SPF record')),
26-
('active', models.BooleanField(default=True, help_text='Whether this provider is currently available for selection')),
27-
('notes', models.TextField(blank=True, help_text='Internal notes about this provider')),
28-
('created_at', models.DateTimeField(auto_now_add=True)),
29-
('updated_at', models.DateTimeField(auto_now=True)),
16+
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
17+
(
18+
"name",
19+
models.CharField(
20+
help_text="Name of the email provider (e.g., 'Google Workspace', 'SendGrid')",
21+
max_length=100,
22+
unique=True,
23+
),
24+
),
25+
(
26+
"category",
27+
models.CharField(
28+
choices=[
29+
("EMAIL_HOSTING", "Email Hosting"),
30+
("TRANSACTIONAL", "Transactional Email"),
31+
("OTHER", "Other"),
32+
],
33+
help_text="Category of email provider",
34+
max_length=20,
35+
),
36+
),
37+
("description", models.TextField(blank=True, help_text="Public description of the provider")),
38+
(
39+
"mechanism_type",
40+
models.CharField(
41+
choices=[
42+
("include", "Include"),
43+
("a", "A Record"),
44+
("mx", "MX Record"),
45+
("ip4", "IPv4"),
46+
("ip6", "IPv6"),
47+
("exists", "Exists"),
48+
],
49+
help_text="Type of SPF mechanism used",
50+
max_length=10,
51+
),
52+
),
53+
(
54+
"mechanism_value",
55+
models.CharField(
56+
help_text="The actual SPF mechanism value (e.g., 'include:_spf.google.com')", max_length=255
57+
),
58+
),
59+
(
60+
"lookup_count",
61+
models.PositiveSmallIntegerField(
62+
default=1, help_text="Number of DNS lookups this mechanism requires"
63+
),
64+
),
65+
(
66+
"priority",
67+
models.PositiveSmallIntegerField(
68+
default=100, help_text="Order in which this should appear in combined SPF record"
69+
),
70+
),
71+
(
72+
"active",
73+
models.BooleanField(
74+
default=True, help_text="Whether this provider is currently available for selection"
75+
),
76+
),
77+
("notes", models.TextField(blank=True, help_text="Internal notes about this provider")),
78+
("created_at", models.DateTimeField(auto_now_add=True)),
79+
("updated_at", models.DateTimeField(auto_now=True)),
3080
],
3181
options={
32-
'ordering': ['priority', 'name'],
82+
"ordering": ["priority", "name"],
3383
},
3484
),
3585
]

spf_generator/templatetags/spf_generator_filters.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Custom template filters for spf_generator app."""
2-
# your_app_name/templatetags/spf_generator_filters.py
2+
3+
from __future__ import annotations
34

45
from typing import TYPE_CHECKING
56

@@ -28,15 +29,15 @@ def startswith(text: str, starts: str) -> bool:
2829

2930

3031
@register.filter
31-
def get_provider(providers_dict: dict[int, EmailProvider], field_name: str) -> EmailProvider:
32+
def get_provider(providers_dict: dict, field_name: str) -> EmailProvider:
3233
"""Template filter to get provider object from field name.
3334
3435
Args:
3536
providers_dict: Dictionary of providers
3637
field_name: Form field name (e.g., 'provider_1')
3738
3839
Returns:
39-
EmailProvider: The provider object or None
40+
EmailProvider: The provider object
4041
"""
4142
provider_id = int(field_name.split("_")[1])
4243

0 commit comments

Comments
 (0)