Skip to content

Commit 1115595

Browse files
committed
Merge branch 'main' into rel
2 parents d467ef4 + 79d8344 commit 1115595

File tree

11 files changed

+64
-11
lines changed

11 files changed

+64
-11
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.2.7 on 2025-11-01 16:57
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('adserver', '0104_auto_renew_payment_method'),
10+
('adserver_auth', '0010_data_all_emails_verified'),
11+
]
12+
13+
operations = [
14+
migrations.AlterUniqueTogether(
15+
name='useradvertisermember',
16+
unique_together={('user', 'advertiser')},
17+
),
18+
]

adserver/auth/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ class Meta:
255255
# To do that, we needed to start with the same table
256256
db_table = "adserver_auth_user_advertisers"
257257

258+
unique_together = ("user", "advertiser")
259+
258260

259261
class UserPublisherMember(models.Model):
260262
"""User-Publisher 'through' model."""

adserver/forms.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,16 @@ def save(self, commit=True):
903903
for field in fields:
904904
setattr(self.instance, field, getattr(self.old_flight, field))
905905

906+
# Set sold impressions/clicks appropriately based on supplied budget
907+
if self.cleaned_data["budget"] > 0 and self.instance.cpm > 0:
908+
self.instance.sold_impressions = int(
909+
self.cleaned_data["budget"] * 1000 / float(self.instance.cpm)
910+
)
911+
elif self.cleaned_data["budget"] > 0 and self.instance.cpc > 0:
912+
self.instance.sold_clicks = int(
913+
self.cleaned_data["budget"] / float(self.instance.cpc)
914+
)
915+
906916
# We must set the campaign
907917
self.instance.campaign = (
908918
self.old_flight.campaign

adserver/tests/test_advertiser_dashboard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,7 @@ def test_authorized_users_invite_existing(self):
12521252
self.assertContains(response, "Successfully invited")
12531253
self.assertEqual(User.objects.filter(email=email).count(), 1)
12541254
self.assertEqual(User.objects.filter(name=name).count(), 1)
1255+
self.assertEqual(UserAdvertiserMember.objects.filter(advertiser=self.advertiser, user__email=email).count(), 1)
12551256

12561257
# The 2nd request didn't create a user or update the user's name
12571258
self.assertEqual(User.objects.filter(name="Yet Another User").count(), 0)

adserver/views.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,13 +1857,16 @@ def dispatch(self, request, *args, **kwargs):
18571857
def form_valid(self, form):
18581858
result = super().form_valid(form)
18591859

1860-
# Add m2m and role
1861-
role = form.cleaned_data["role"]
1862-
UserAdvertiserMember.objects.create(
1863-
advertiser=self.advertiser,
1864-
user=self.object,
1865-
role=role,
1866-
)
1860+
if not UserAdvertiserMember.objects.filter(
1861+
advertiser=self.advertiser, user=self.object
1862+
).exists():
1863+
# Add m2m and role
1864+
role = form.cleaned_data["role"]
1865+
UserAdvertiserMember.objects.create(
1866+
advertiser=self.advertiser,
1867+
user=self.object,
1868+
role=role,
1869+
)
18671870

18681871
messages.success(
18691872
self.request,

config/settings/production.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
USE_DB_POOLING = env.bool("USE_DB_POOLING", default=False)
4646
for db in ("default", "replica"):
4747
if db in DATABASES:
48+
# https://docs.djangoproject.com/en/dev/topics/db/transactions/#tying-transactions-to-http-requests
49+
DATABASES[db]["ATOMIC_REQUESTS"] = True
50+
4851
if "OPTIONS" not in DATABASES[db]:
4952
DATABASES[db]["OPTIONS"] = {}
5053

@@ -66,6 +69,16 @@
6669
"propagate": False,
6770
}
6871

72+
# The analyzer can log very verbosely on error URLs
73+
LOGGING["loggers"]["trafilatura.downloads"] = {
74+
"handlers": ["null"],
75+
"propagate": False,
76+
}
77+
LOGGING["loggers"]["trafilatura.core"] = {
78+
"handlers": ["null"],
79+
"propagate": False,
80+
}
81+
6982

7083
# Cache
7184
# https://docs.djangoproject.com/en/dev/topics/cache/

requirements/analyzer.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Used by the keyword/topic analyzer
22
beautifulsoup4
33
textacy
4+
markdownify >= 1.2.0
45

56
# Must pin to a version compatible with the spacy-model below
67
spacy[transformers] >=3.8.7,< 4.0

requirements/analyzer.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ azure-storage-blob==12.26.0
3636
babel==2.17.0
3737
# via courlan
3838
beautifulsoup4==4.13.5
39-
# via -r analyzer.in
39+
# via
40+
# -r analyzer.in
41+
# markdownify
4042
blis==1.2.1
4143
# via thinc
4244
boto3==1.40.39
@@ -176,6 +178,8 @@ marisa-trie==1.3.1
176178
# via language-data
177179
markdown-it-py==4.0.0
178180
# via rich
181+
markdownify==1.2.0
182+
# via -r analyzer.in
179183
markupsafe==3.0.2
180184
# via jinja2
181185
mdurl==0.1.2
@@ -345,6 +349,7 @@ six==1.17.0
345349
# via
346350
# azure-core
347351
# langdetect
352+
# markdownify
348353
# python-dateutil
349354
smart-open==7.3.1
350355
# via weasel

requirements/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cryptography==45.0.6
5454
# via fido2
5555
dj-stripe==2.8.4
5656
# via -r base.in
57-
django==5.2.7
57+
django==5.2.8
5858
# via
5959
# -r base.in
6060
# crispy-bootstrap4

requirements/development.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ distlib==0.4.0
8686
# via virtualenv
8787
dj-stripe==2.8.4
8888
# via -r base.in
89-
django==5.2.7
89+
django==5.2.8
9090
# via
9191
# -r base.in
9292
# crispy-bootstrap4

0 commit comments

Comments
 (0)