diff --git a/dmoj/settings.py b/dmoj/settings.py index 9b1b268..c54c591 100644 --- a/dmoj/settings.py +++ b/dmoj/settings.py @@ -325,7 +325,6 @@ TEMPLATES = [ "judge.template_context.site", "judge.template_context.site_name", "judge.template_context.misc_config", - "judge.template_context.math_setting", "social_django.context_processors.backends", "social_django.context_processors.login_redirect", ], diff --git a/dmoj/urls.py b/dmoj/urls.py index a7dacb8..1fc560f 100644 --- a/dmoj/urls.py +++ b/dmoj/urls.py @@ -1195,8 +1195,8 @@ urlpatterns = [ url(r"^resolver/(?P\w+)", resolver.Resolver.as_view(), name="resolver"), ] + url_static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) -# if hasattr(settings, "INTERNAL_IPS"): -# urlpatterns.append(url("__debug__/", include("debug_toolbar.urls"))) +if hasattr(settings, "INTERNAL_IPS"): + urlpatterns.append(url("__debug__/", include("debug_toolbar.urls"))) favicon_paths = [ "apple-touch-icon-180x180.png", diff --git a/judge/admin/profile.py b/judge/admin/profile.py index 65522b3..4b5427b 100644 --- a/judge/admin/profile.py +++ b/judge/admin/profile.py @@ -63,7 +63,6 @@ class ProfileAdmin(VersionAdmin): "timezone", "language", "ace_theme", - "math_engine", "last_access", "ip", "mute", diff --git a/judge/fixtures/demo.json b/judge/fixtures/demo.json index 64b3012..328f935 100644 --- a/judge/fixtures/demo.json +++ b/judge/fixtures/demo.json @@ -8,7 +8,6 @@ "ip": "10.0.2.2", "language": 1, "last_access": "2017-12-02T08:57:10.093Z", - "math_engine": "auto", "mute": false, "organizations": [ 1 diff --git a/judge/forms.py b/judge/forms.py index 4c5b49e..0f42ca1 100644 --- a/judge/forms.py +++ b/judge/forms.py @@ -88,11 +88,6 @@ class ProfileForm(ModelForm): "css_background": forms.TextInput(), } - has_math_config = bool(settings.MATHOID_URL) - if has_math_config: - fields.append("math_engine") - widgets["math_engine"] = Select2Widget(attrs={"style": "width:200px"}) - if HeavyPreviewPageDownWidget is not None: widgets["about"] = HeavyPreviewPageDownWidget( preview=reverse_lazy("profile_preview"), diff --git a/judge/management/commands/render_pdf.py b/judge/management/commands/render_pdf.py index 7900420..87324b4 100644 --- a/judge/management/commands/render_pdf.py +++ b/judge/management/commands/render_pdf.py @@ -89,7 +89,6 @@ class Command(BaseCommand): if trans is None else trans.description, "url": "", - "math_engine": maker.math_engine, } ) .replace('"//', '"https://') diff --git a/judge/migrations/0181_remove_math_engine.py b/judge/migrations/0181_remove_math_engine.py new file mode 100644 index 0000000..99e4a85 --- /dev/null +++ b/judge/migrations/0181_remove_math_engine.py @@ -0,0 +1,50 @@ +# Generated by Django 3.2.18 on 2024-02-26 20:43 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ("judge", "0180_course"), + ] + + operations = [ + migrations.RemoveField( + model_name="profile", + name="math_engine", + ), + migrations.AlterField( + model_name="course", + name="about", + field=models.TextField(verbose_name="course description"), + ), + migrations.AlterField( + model_name="courselesson", + name="course", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="lessons", + to="judge.course", + verbose_name="course", + ), + ), + migrations.AlterField( + model_name="courselesson", + name="problems", + field=models.ManyToManyField( + blank=True, to="judge.Problem", verbose_name="problem" + ), + ), + migrations.AlterField( + model_name="courserole", + name="user", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="course_roles", + to="judge.profile", + verbose_name="user", + ), + ), + ] diff --git a/judge/models/__init__.py b/judge/models/__init__.py index 89b5d2e..ca4acbd 100644 --- a/judge/models/__init__.py +++ b/judge/models/__init__.py @@ -2,8 +2,6 @@ from reversion import revisions from judge.models.choices import ( ACE_THEMES, - EFFECTIVE_MATH_ENGINES, - MATH_ENGINES_CHOICES, TIMEZONE, ) from judge.models.comment import Comment, CommentLock, CommentVote diff --git a/judge/models/choices.py b/judge/models/choices.py index b6fab5c..105e7e7 100644 --- a/judge/models/choices.py +++ b/judge/models/choices.py @@ -54,13 +54,3 @@ ACE_THEMES = ( ("vibrant_ink", "Vibrant Ink"), ("xcode", "XCode"), ) - -MATH_ENGINES_CHOICES = ( - ("tex", _("Leave as LaTeX")), - ("svg", _("SVG with PNG fallback")), - ("mml", _("MathML only")), - ("jax", _("MathJax with SVG/PNG fallback")), - ("auto", _("Detect best quality")), -) - -EFFECTIVE_MATH_ENGINES = ("svg", "mml", "tex", "jax") diff --git a/judge/models/profile.py b/judge/models/profile.py index bee95f6..2d0d6c7 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -17,7 +17,7 @@ from django.db.models.signals import post_save, pre_save from fernet_fields import EncryptedCharField from sortedm2m.fields import SortedManyToManyField -from judge.models.choices import ACE_THEMES, MATH_ENGINES_CHOICES, TIMEZONE +from judge.models.choices import ACE_THEMES, TIMEZONE from judge.models.runtime import Language from judge.ratings import rating_class from judge.caching import cache_wrapper @@ -215,13 +215,6 @@ class Profile(models.Model): related_name="+", on_delete=models.SET_NULL, ) - math_engine = models.CharField( - verbose_name=_("math engine"), - choices=MATH_ENGINES_CHOICES, - max_length=4, - default=settings.MATHOID_DEFAULT_TYPE, - help_text=_("the rendering engine used to render math"), - ) is_totp_enabled = models.BooleanField( verbose_name=_("2FA enabled"), default=False, diff --git a/judge/signals.py b/judge/signals.py index 7987bbd..dfb2a54 100644 --- a/judge/signals.py +++ b/judge/signals.py @@ -14,7 +14,6 @@ from .models import ( Comment, Contest, ContestSubmission, - EFFECTIVE_MATH_ENGINES, Judge, Language, License, @@ -52,9 +51,8 @@ def problem_update(sender, instance, **kwargs): ) cache.delete_many( [ - make_template_fragment_key("problem_html", (instance.id, engine, lang)) + make_template_fragment_key("problem_html", (instance.id, lang)) for lang, _ in settings.LANGUAGES - for engine in EFFECTIVE_MATH_ENGINES ] ) cache.delete_many( @@ -80,10 +78,7 @@ def profile_update(sender, instance, **kwargs): return cache.delete_many( - [ - make_template_fragment_key("user_about", (instance.id, engine)) - for engine in EFFECTIVE_MATH_ENGINES - ] + [make_template_fragment_key("user_about", (instance.id))] + [ make_template_fragment_key("org_member_count", (org_id,)) for org_id in instance.organizations.values_list("id", flat=True) @@ -98,10 +93,7 @@ def contest_update(sender, instance, **kwargs): cache.delete_many( ["generated-meta-contest:%d" % instance.id] - + [ - make_template_fragment_key("contest_html", (instance.id, engine)) - for engine in EFFECTIVE_MATH_ENGINES - ] + + [make_template_fragment_key("contest_html", (instance.id))] ) @@ -136,12 +128,7 @@ def post_update(sender, instance, **kwargs): "blog_feed:%d" % instance.id, ] ) - cache.delete_many( - [ - make_template_fragment_key("post_content", (instance.id, engine)) - for engine in EFFECTIVE_MATH_ENGINES - ] - ) + cache.delete_many([make_template_fragment_key("post_content", (instance.id))]) @receiver(post_delete, sender=Submission) @@ -158,12 +145,7 @@ def contest_submission_delete(sender, instance, **kwargs): @receiver(post_save, sender=Organization) def organization_update(sender, instance, **kwargs): - cache.delete_many( - [ - make_template_fragment_key("organization_html", (instance.id, engine)) - for engine in EFFECTIVE_MATH_ENGINES - ] - ) + cache.delete_many([make_template_fragment_key("organization_html", (instance.id))]) _misc_config_i18n = [code for code, _ in settings.LANGUAGES] diff --git a/judge/template_context.py b/judge/template_context.py index ced05ae..9cdb4c1 100644 --- a/judge/template_context.py +++ b/judge/template_context.py @@ -118,13 +118,3 @@ def site_name(request): "SITE_LONG_NAME": settings.SITE_LONG_NAME, "SITE_ADMIN_EMAIL": settings.SITE_ADMIN_EMAIL, } - - -def math_setting(request): - if request.user.is_authenticated: - engine = request.profile.math_engine - else: - engine = settings.MATHOID_DEFAULT_TYPE - if engine == "auto": - engine = "jax" - return {"MATH_ENGINE": engine, "REQUIRE_JAX": engine == "jax"} diff --git a/judge/views/problem.py b/judge/views/problem.py index 7230d12..d673e5c 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -399,7 +399,6 @@ class ProblemPdfView(ProblemMixin, SingleObjectMixin, View): if trans is None else trans.description, "url": request.build_absolute_uri(), - "math_engine": maker.math_engine, } ) .replace('"//', '"https://') diff --git a/judge/views/user.py b/judge/views/user.py index bfbba08..01aa7d6 100644 --- a/judge/views/user.py +++ b/judge/views/user.py @@ -430,7 +430,6 @@ def edit_profile(request): "form": form, "title": _("Edit profile"), "profile": profile, - "has_math_config": bool(settings.MATHOID_URL), "TIMEZONE_MAP": tzmap or "http://momentjs.com/static/img/world.png", "TIMEZONE_BG": settings.TIMEZONE_BG if tzmap else "#4E7CAD", }, diff --git a/resources/pagedown_math.js b/resources/pagedown_math.js index fb3f2af..861ef78 100644 --- a/resources/pagedown_math.js +++ b/resources/pagedown_math.js @@ -1,4 +1,4 @@ -function mathjax_pagedown($) { +function latex_pagedown($) { $.each(window.editors, function (id, editor) { var preview = $('div.wmd-preview#' + id + '_wmd_preview')[0]; editor.hooks.chain('onPreviewRefresh', function () { @@ -8,8 +8,8 @@ function mathjax_pagedown($) { }); } -window.mathjax_pagedown = mathjax_pagedown; +window.latex_pagedown = latex_pagedown; $(function () { - (mathjax_pagedown)('$' in window ? $ : django.jQuery); + (latex_pagedown)('$' in window ? $ : django.jQuery); }); \ No newline at end of file diff --git a/templates/about/about.html b/templates/about/about.html index 7924c6e..ce978de 100644 --- a/templates/about/about.html +++ b/templates/about/about.html @@ -2,7 +2,7 @@ {% block body %} {% if request.organization %} - {% cache 3600 'organization_html' request.organization.id MATH_ENGINE %} + {% cache 3600 'organization_html' request.organization.id %} {{ request.organization.about|markdown|reference|str|safe }} {% endcache %} {% else %} diff --git a/templates/blog/blog.html b/templates/blog/blog.html index ac6d807..6793ba0 100644 --- a/templates/blog/blog.html +++ b/templates/blog/blog.html @@ -37,7 +37,7 @@ {% endif %}
- {% cache 86400 'post_content' post.id MATH_ENGINE %} + {% cache 86400 'post_content' post.id %} {{ post.content|markdown|reference|str|safe}} {% endcache %}
diff --git a/templates/contest/contest.html b/templates/contest/contest.html index 1b454dc..3c40b67 100644 --- a/templates/contest/contest.html +++ b/templates/contest/contest.html @@ -105,7 +105,7 @@ {% endif %}
- {% cache 3600 'contest_html' contest.id MATH_ENGINE %} + {% cache 3600 'contest_html' contest.id %} {{ contest.description|markdown|reference|str|safe }} {% endcache %}
diff --git a/templates/organization/home.html b/templates/organization/home.html index 1723a95..dd167be 100644 --- a/templates/organization/home.html +++ b/templates/organization/home.html @@ -40,7 +40,7 @@

{{ _('About') }}