diff --git a/quiz/management/commands/auto_publish.py b/quiz/management/commands/auto_publish.py index 5ed9a9e..85db793 100644 --- a/quiz/management/commands/auto_publish.py +++ b/quiz/management/commands/auto_publish.py @@ -12,23 +12,23 @@ class Command(BaseCommand): def add_arguments(self, parser): - parser.add_argument('--skip-tweet', action='store_true') + parser.add_argument('--skip-socials', action='store_true') def handle(self, *args, **options): - skip_tweet = options["skip_tweet"] + skip_socials = options["skip_socials"] for q in Question.objects.filter(state='SCH', publish_time__lte=timezone.now()): print(f"Publishing question {q}") q.state = 'PUB' q.save() - if (q.tweet_text): - print(f"Posting to Twitter: '{q.tweet_text}'") - if skip_tweet: - print("Skipping!") + if (q.socials_text): + if skip_socials: + print("Skipping posting to social media!") else: - self.tweet(q.tweet_text) + self.post_to_x(q.socials_text) - def tweet(self, content): + def post_to_x(self, content): + print(f"Posting to X: '{content}'") try: secrets_file = Path.home() / ".cppquiz-secrets.json" with secrets_file.open() as f: @@ -41,7 +41,7 @@ def tweet(self, content): response = client.create_tweet( text=content ) - print(f"Posted https://twitter.com/user/status/{response.data['id']}") + print(f"Posted https://x.com/user/status/{response.data['id']}") except Exception as e: - print(f"Failed to tweet '{content}' due to exception '{e}'") + print(f"Failed to post '{content}' to X due to exception '{e}'") sys.exit(1) diff --git a/quiz/management/commands/text_generator.py b/quiz/management/commands/text_generator.py index d4a30ca..fdfda79 100644 --- a/quiz/management/commands/text_generator.py +++ b/quiz/management/commands/text_generator.py @@ -106,7 +106,7 @@ def get_result_display(question): - Other ideas for help are also welcome, please get in touch (see [Questions](#questions) below). ### Questions -If you have any questions, either file an issue in this repo, contact [@knatten on Twitter](https://twitter.com/knatten), or email me at anders@knatten.org. +If you have any questions, either file an issue in this repo, contact [@knatten on X](https://x.com/knatten), or email me at anders@knatten.org. """ pull_request_template = """ Fixes # (Make sure to enter the issue number, not the question number! If this PR fixes multiple issues, just duplicate this line.) diff --git a/quiz/migrations/0023_rename_tweet_text_question_socials_text.py b/quiz/migrations/0023_rename_tweet_text_question_socials_text.py new file mode 100644 index 0000000..db2e15b --- /dev/null +++ b/quiz/migrations/0023_rename_tweet_text_question_socials_text.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.15 on 2024-09-22 14:19 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('quiz', '0022_alter_question_result_alter_usersanswer_result'), + ] + + operations = [ + migrations.RenameField( + model_name='question', + old_name='tweet_text', + new_name='socials_text', + ), + ] diff --git a/quiz/models.py b/quiz/models.py index 0e58276..98c3076 100644 --- a/quiz/models.py +++ b/quiz/models.py @@ -55,8 +55,8 @@ class Question(models.Model): help_text='This question is reserved for an event, do not publish yet') reservation_message = models.CharField(blank=True, max_length=100, help_text='Which event the question is reserved for') - tweet_text = models.CharField(blank=True, max_length=280, - help_text='What to tweet when question gets posted on Twitter') + socials_text = models.CharField(blank=True, max_length=280, + help_text='What to post when question gets posted on social media') def __str__(self): return str(self.pk) @@ -69,7 +69,7 @@ def clean(self): raise ValidationError(f'Cannot {verbs[self.state]} a question without a difficulty setting') if self.state in ('PUB', 'SCH') and self.reserved: raise ValidationError(f'Cannot {verbs[self.state]} a reserved question') - if self.tweet_text and not re.search("https?://", self.tweet_text): + if self.socials_text and not re.search("https?://", self.socials_text): raise ValidationError('Tweets must contain a url!') def save(self, *args, **kwargs): diff --git a/quiz/static/quiz.css b/quiz/static/quiz.css index 0dc40de..8c6c3ba 100644 --- a/quiz/static/quiz.css +++ b/quiz/static/quiz.css @@ -182,13 +182,13 @@ h4.quiz_mode { color:#999; } -.twitter-follow { +.x-follow { background-color: #1da1f2; border-radius: 3px; padding: 1px 8px 1px 6px; font-family: "Helvetica Neue", Arial, sans-serif; } -#footer a.twitter-follow { +#footer a.x-follow { color: #fff; } #info_page { diff --git a/quiz/static/twitter.png b/quiz/static/x.png similarity index 100% rename from quiz/static/twitter.png rename to quiz/static/x.png diff --git a/quiz/tests/unit/test_auto_publish.py b/quiz/tests/unit/test_auto_publish.py index 144facd..a81e416 100644 --- a/quiz/tests/unit/test_auto_publish.py +++ b/quiz/tests/unit/test_auto_publish.py @@ -13,17 +13,17 @@ class AutoPublishTest(TestCase): def test_publishes_scheduled_question_from_the_past(self): past = timezone.now() - timedelta(hours=1) [q] = create_questions(1, state="SCH", publish_time=past) - call_command("auto_publish", "--skip-tweet") + call_command("auto_publish", "--skip-socials") self.assertEqual("PUB", Question.objects.get(pk=q.pk).state) def test_does_not_publish_unscheduled_question_from_the_past(self): past = timezone.now() - timedelta(hours=1) [q] = create_questions(1, state="ACC", publish_time=past) - call_command("auto_publish", "--skip-tweet") + call_command("auto_publish", "--skip-socials") self.assertEqual("ACC", Question.objects.get(pk=q.pk).state) def test_does_not_publish_scheduled_question_from_the_future(self): future = timezone.now() + timedelta(hours=1) [q] = create_questions(1, state="SCH", publish_time=future) - call_command("auto_publish", "--skip-tweet") + call_command("auto_publish", "--skip-socials") self.assertEqual("SCH", Question.objects.get(pk=q.pk).state) diff --git a/quiz/tests/unit/test_models.py b/quiz/tests/unit/test_models.py index 32d5a13..a8fea5c 100644 --- a/quiz/tests/unit/test_models.py +++ b/quiz/tests/unit/test_models.py @@ -49,10 +49,10 @@ def test_questions_get_a_random_preview_key(self): q2 = Question.objects.create() self.assertNotEqual(q.preview_key, q2.preview_key) - def test_requires_url_in_tweet_text(self): - q = Question(state="SCH", hint='hint', tweet_text="hi", difficulty=1) + 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)) - Question(state="SCH", hint='hint', tweet_text="See http://example.com", difficulty=1).save() - Question(state="SCH", hint='hint', tweet_text="See https://example.com", difficulty=1).save() + 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() diff --git a/templates/base.html b/templates/base.html index 715875e..ce5bb2b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -107,7 +107,7 @@

C++ Quiz

CoC | Mastodon Mastodon | Bluesky Bluesky | -Twitter Twitter | +X X | © Anders Schau Knatten {% now "Y"%}.

diff --git a/templates/quiz/finished.html b/templates/quiz/finished.html index 3d9cbed..42feb41 100644 --- a/templates/quiz/finished.html +++ b/templates/quiz/finished.html @@ -20,9 +20,9 @@

All right!

You finished with {{quiz_in_progress.score|floatformat:2}} out of {{quiz_in_progress.get_total_nof_questions|floatformat:1}} possible points.

-Now boast about it on Twitter! +Now boast about it on X!
-(This link takes you to Twitter.com, we would never post on your behalf). +(This link takes you to x.com, we would never post on your behalf).

diff --git a/templates/quiz/help.html b/templates/quiz/help.html index f771e2b..0d88404 100644 --- a/templates/quiz/help.html +++ b/templates/quiz/help.html @@ -4,7 +4,7 @@ Continue quiz

About

-C++ Quiz is written by Anders Schau Knatten with valuable input from Olve Maudal, Fernando Cacciola, other members of the ACCU, and several other contributors. If you discover any errors, or would like to contribute, please contact me at anders AT knatten.org, on Twitter, or on GitHub. +C++ Quiz is written by Anders Schau Knatten with valuable input from Olve Maudal, Fernando Cacciola, other members of the ACCU, and several other contributors. If you discover any errors, or would like to contribute, please contact me at anders AT knatten.org, on X, or on GitHub.

Help/FAQ

What is this?

@@ -21,7 +21,7 @@

What features are planned?

See open issues on GitHub.

How can I help?

-

If you know C++, by adding more questions, or joining our mailing-list cppquiz-discuss@cppquiz.org. If you know Python/Django/JavaScript, by extending functionality. If you know web-design, by improving the design. Please contact me at anders AT knatten.org or Twitter.

+

If you know C++, by adding more questions, or joining our mailing-list cppquiz-discuss@cppquiz.org. If you know Python/Django/JavaScript, by extending functionality. If you know web-design, by improving the design. Please contact me at anders AT knatten.org or X.

Cookies