Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions quiz/management/commands/auto_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import datetime
from pathlib import Path

import tweepy
from django.core.mail import mail_admins
from django.core.management.base import BaseCommand
from django.utils import timezone

Expand Down Expand Up @@ -37,7 +35,6 @@ def handle(self, *args, **options):

def post_to_socials(self, content):
platforms = [
("X", self.post_to_x),
("Bluesky", lambda: self.post_to_bluesky(content)),
("Mastodon", lambda: self.post_to_mastodon(content)),
]
Expand All @@ -51,20 +48,6 @@ def post_to_socials(self, content):
traceback.print_exc()
return had_failure

def post_to_x(self):
content = "We just published a new question! Follow us on Bluesky @cppquiz.bsky.social or Mastodon @cppquiz@mastodon.online for updates. For obvious reasons, no longer post to Elon Musk's X."
print(f"Posting to X: '{content}'")
secrets = self.read_secrets()

client = tweepy.Client(
consumer_key=secrets["consumer_key"], consumer_secret=secrets["consumer_secret"],
access_token=secrets["access_token"], access_token_secret=secrets["access_token_secret"],
)
response = client.create_tweet(
text=content
)
post_url = f"https://x.com/user/status/{response.data['id']}"

def post_to_bluesky(self, content):
print(f"Posting to Bluesky: '{content}'")
secrets = self.read_secrets()
Expand Down
2 changes: 1 addition & 1 deletion quiz/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def clean(self):
if self.state in ('PUB', 'SCH') and self.reserved:
raise ValidationError(f'Cannot {verbs[self.state]} a reserved question')
if self.socials_text and not re.search("https?://", self.socials_text):
raise ValidationError('Tweets must contain a url!')
raise ValidationError('Social media messages must contain a url!')

def save(self, *args, **kwargs):
self.full_clean()
Expand Down
2 changes: 1 addition & 1 deletion quiz/tests/unit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_requires_url_in_socials_text(self):
q = Question(state="SCH", hint='hint', socials_text="hi", difficulty=1)
with self.assertRaises(ValidationError) as cm:
q.save()
self.assertIn('Tweets must contain a url!', str(cm.exception))
self.assertIn('Social media messages must contain a url!', str(cm.exception))
Question(state="SCH", hint='hint', socials_text="See http://example.com", difficulty=1).save()
Question(state="SCH", hint='hint', socials_text="See https://example.com", difficulty=1).save()

Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Django>=5,<6
Markdown
requests
pymdown-extensions
mock
parameterized
tweepy
autopep8
pip-tools
pytest
Expand Down
24 changes: 7 additions & 17 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.13
# This file is autogenerated by pip-compile with Python 3.14
# by the following command:
#
# pip-compile requirements.in
Expand All @@ -10,13 +10,13 @@ autopep8==2.3.2
# via -r requirements.in
build==1.5.0
# via pip-tools
certifi==2026.5.20
certifi==2026.6.17
# via requests
charset-normalizer==3.4.7
# via requests
clang-format==22.1.5
# via -r requirements.in
click==8.4.1
click==8.4.2
# via pip-tools
cssselect==1.4.0
# via splinter
Expand All @@ -25,7 +25,7 @@ django==5.2.15
# -r requirements.in
# django-reversion
# splinter
django-reversion==6.2.0
django-reversion==6.3.0
# via -r requirements.in
idna==3.18
# via requests
Expand All @@ -39,10 +39,6 @@ markdown==3.10.2
# pymdown-extensions
mock==5.2.0
# via -r requirements.in
oauthlib==3.3.1
# via
# requests-oauthlib
# tweepy
packaging==26.2
# via
# build
Expand All @@ -58,13 +54,13 @@ pycodestyle==2.14.0
# via autopep8
pygments==2.20.0
# via pytest
pymdown-extensions==10.21.3
pymdown-extensions==11.0
# via -r requirements.in
pyproject-hooks==1.2.0
# via
# build
# pip-tools
pytest==9.0.3
pytest==9.1.1
# via
# -r requirements.in
# pytest-django
Expand All @@ -73,17 +69,11 @@ pytest-django==4.12.0
pyyaml==6.0.3
# via pymdown-extensions
requests==2.34.2
# via
# requests-oauthlib
# tweepy
requests-oauthlib==2.0.0
# via tweepy
# via -r requirements.in
splinter[django]==0.21.0
# via -r requirements.in
sqlparse==0.5.5
# via django
tweepy==4.16.0
# via -r requirements.in
urllib3==2.7.0
# via
# requests
Expand Down
Loading