Remove math engines

This commit is contained in:
cuom1999 2024-02-26 14:49:52 -06:00
parent 3f53c62d4d
commit 1e7957a2cd
22 changed files with 67 additions and 81 deletions

View file

@ -325,7 +325,6 @@ TEMPLATES = [
"judge.template_context.site", "judge.template_context.site",
"judge.template_context.site_name", "judge.template_context.site_name",
"judge.template_context.misc_config", "judge.template_context.misc_config",
"judge.template_context.math_setting",
"social_django.context_processors.backends", "social_django.context_processors.backends",
"social_django.context_processors.login_redirect", "social_django.context_processors.login_redirect",
], ],

View file

@ -1195,8 +1195,8 @@ urlpatterns = [
url(r"^resolver/(?P<contest>\w+)", resolver.Resolver.as_view(), name="resolver"), url(r"^resolver/(?P<contest>\w+)", resolver.Resolver.as_view(), name="resolver"),
] + url_static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + url_static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# if hasattr(settings, "INTERNAL_IPS"): if hasattr(settings, "INTERNAL_IPS"):
# urlpatterns.append(url("__debug__/", include("debug_toolbar.urls"))) urlpatterns.append(url("__debug__/", include("debug_toolbar.urls")))
favicon_paths = [ favicon_paths = [
"apple-touch-icon-180x180.png", "apple-touch-icon-180x180.png",

View file

@ -63,7 +63,6 @@ class ProfileAdmin(VersionAdmin):
"timezone", "timezone",
"language", "language",
"ace_theme", "ace_theme",
"math_engine",
"last_access", "last_access",
"ip", "ip",
"mute", "mute",

View file

@ -8,7 +8,6 @@
"ip": "10.0.2.2", "ip": "10.0.2.2",
"language": 1, "language": 1,
"last_access": "2017-12-02T08:57:10.093Z", "last_access": "2017-12-02T08:57:10.093Z",
"math_engine": "auto",
"mute": false, "mute": false,
"organizations": [ "organizations": [
1 1

View file

@ -88,11 +88,6 @@ class ProfileForm(ModelForm):
"css_background": forms.TextInput(), "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: if HeavyPreviewPageDownWidget is not None:
widgets["about"] = HeavyPreviewPageDownWidget( widgets["about"] = HeavyPreviewPageDownWidget(
preview=reverse_lazy("profile_preview"), preview=reverse_lazy("profile_preview"),

View file

@ -89,7 +89,6 @@ class Command(BaseCommand):
if trans is None if trans is None
else trans.description, else trans.description,
"url": "", "url": "",
"math_engine": maker.math_engine,
} }
) )
.replace('"//', '"https://') .replace('"//', '"https://')

View file

@ -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",
),
),
]

View file

@ -2,8 +2,6 @@ from reversion import revisions
from judge.models.choices import ( from judge.models.choices import (
ACE_THEMES, ACE_THEMES,
EFFECTIVE_MATH_ENGINES,
MATH_ENGINES_CHOICES,
TIMEZONE, TIMEZONE,
) )
from judge.models.comment import Comment, CommentLock, CommentVote from judge.models.comment import Comment, CommentLock, CommentVote

View file

@ -54,13 +54,3 @@ ACE_THEMES = (
("vibrant_ink", "Vibrant Ink"), ("vibrant_ink", "Vibrant Ink"),
("xcode", "XCode"), ("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")

View file

@ -17,7 +17,7 @@ from django.db.models.signals import post_save, pre_save
from fernet_fields import EncryptedCharField from fernet_fields import EncryptedCharField
from sortedm2m.fields import SortedManyToManyField 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.models.runtime import Language
from judge.ratings import rating_class from judge.ratings import rating_class
from judge.caching import cache_wrapper from judge.caching import cache_wrapper
@ -215,13 +215,6 @@ class Profile(models.Model):
related_name="+", related_name="+",
on_delete=models.SET_NULL, 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( is_totp_enabled = models.BooleanField(
verbose_name=_("2FA enabled"), verbose_name=_("2FA enabled"),
default=False, default=False,

View file

@ -14,7 +14,6 @@ from .models import (
Comment, Comment,
Contest, Contest,
ContestSubmission, ContestSubmission,
EFFECTIVE_MATH_ENGINES,
Judge, Judge,
Language, Language,
License, License,
@ -52,9 +51,8 @@ def problem_update(sender, instance, **kwargs):
) )
cache.delete_many( 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 lang, _ in settings.LANGUAGES
for engine in EFFECTIVE_MATH_ENGINES
] ]
) )
cache.delete_many( cache.delete_many(
@ -80,10 +78,7 @@ def profile_update(sender, instance, **kwargs):
return return
cache.delete_many( cache.delete_many(
[ [make_template_fragment_key("user_about", (instance.id))]
make_template_fragment_key("user_about", (instance.id, engine))
for engine in EFFECTIVE_MATH_ENGINES
]
+ [ + [
make_template_fragment_key("org_member_count", (org_id,)) make_template_fragment_key("org_member_count", (org_id,))
for org_id in instance.organizations.values_list("id", flat=True) for org_id in instance.organizations.values_list("id", flat=True)
@ -98,10 +93,7 @@ def contest_update(sender, instance, **kwargs):
cache.delete_many( cache.delete_many(
["generated-meta-contest:%d" % instance.id] ["generated-meta-contest:%d" % instance.id]
+ [ + [make_template_fragment_key("contest_html", (instance.id))]
make_template_fragment_key("contest_html", (instance.id, engine))
for engine in EFFECTIVE_MATH_ENGINES
]
) )
@ -136,12 +128,7 @@ def post_update(sender, instance, **kwargs):
"blog_feed:%d" % instance.id, "blog_feed:%d" % instance.id,
] ]
) )
cache.delete_many( cache.delete_many([make_template_fragment_key("post_content", (instance.id))])
[
make_template_fragment_key("post_content", (instance.id, engine))
for engine in EFFECTIVE_MATH_ENGINES
]
)
@receiver(post_delete, sender=Submission) @receiver(post_delete, sender=Submission)
@ -158,12 +145,7 @@ def contest_submission_delete(sender, instance, **kwargs):
@receiver(post_save, sender=Organization) @receiver(post_save, sender=Organization)
def organization_update(sender, instance, **kwargs): def organization_update(sender, instance, **kwargs):
cache.delete_many( cache.delete_many([make_template_fragment_key("organization_html", (instance.id))])
[
make_template_fragment_key("organization_html", (instance.id, engine))
for engine in EFFECTIVE_MATH_ENGINES
]
)
_misc_config_i18n = [code for code, _ in settings.LANGUAGES] _misc_config_i18n = [code for code, _ in settings.LANGUAGES]

View file

@ -118,13 +118,3 @@ def site_name(request):
"SITE_LONG_NAME": settings.SITE_LONG_NAME, "SITE_LONG_NAME": settings.SITE_LONG_NAME,
"SITE_ADMIN_EMAIL": settings.SITE_ADMIN_EMAIL, "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"}

View file

@ -399,7 +399,6 @@ class ProblemPdfView(ProblemMixin, SingleObjectMixin, View):
if trans is None if trans is None
else trans.description, else trans.description,
"url": request.build_absolute_uri(), "url": request.build_absolute_uri(),
"math_engine": maker.math_engine,
} }
) )
.replace('"//', '"https://') .replace('"//', '"https://')

View file

@ -430,7 +430,6 @@ def edit_profile(request):
"form": form, "form": form,
"title": _("Edit profile"), "title": _("Edit profile"),
"profile": profile, "profile": profile,
"has_math_config": bool(settings.MATHOID_URL),
"TIMEZONE_MAP": tzmap or "http://momentjs.com/static/img/world.png", "TIMEZONE_MAP": tzmap or "http://momentjs.com/static/img/world.png",
"TIMEZONE_BG": settings.TIMEZONE_BG if tzmap else "#4E7CAD", "TIMEZONE_BG": settings.TIMEZONE_BG if tzmap else "#4E7CAD",
}, },

View file

@ -1,4 +1,4 @@
function mathjax_pagedown($) { function latex_pagedown($) {
$.each(window.editors, function (id, editor) { $.each(window.editors, function (id, editor) {
var preview = $('div.wmd-preview#' + id + '_wmd_preview')[0]; var preview = $('div.wmd-preview#' + id + '_wmd_preview')[0];
editor.hooks.chain('onPreviewRefresh', function () { editor.hooks.chain('onPreviewRefresh', function () {
@ -8,8 +8,8 @@ function mathjax_pagedown($) {
}); });
} }
window.mathjax_pagedown = mathjax_pagedown; window.latex_pagedown = latex_pagedown;
$(function () { $(function () {
(mathjax_pagedown)('$' in window ? $ : django.jQuery); (latex_pagedown)('$' in window ? $ : django.jQuery);
}); });

View file

@ -2,7 +2,7 @@
{% block body %} {% block body %}
{% if request.organization %} {% 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 }} {{ request.organization.about|markdown|reference|str|safe }}
{% endcache %} {% endcache %}
{% else %} {% else %}

View file

@ -37,7 +37,7 @@
{% endif %} {% endif %}
</div> </div>
<div class="body content-description"> <div class="body content-description">
{% cache 86400 'post_content' post.id MATH_ENGINE %} {% cache 86400 'post_content' post.id %}
{{ post.content|markdown|reference|str|safe}} {{ post.content|markdown|reference|str|safe}}
{% endcache %} {% endcache %}
</div> </div>

View file

@ -105,7 +105,7 @@
{% endif %} {% endif %}
<div style="padding: 0 1em;"> <div style="padding: 0 1em;">
{% cache 3600 'contest_html' contest.id MATH_ENGINE %} {% cache 3600 'contest_html' contest.id %}
{{ contest.description|markdown|reference|str|safe }} {{ contest.description|markdown|reference|str|safe }}
{% endcache %} {% endcache %}
</div> </div>

View file

@ -40,7 +40,7 @@
<h3><i class="fa fa-info-circle"></i>{{ _('About') }}</h3> <h3><i class="fa fa-info-circle"></i>{{ _('About') }}</h3>
<div class="sidebox-content"> <div class="sidebox-content">
<div style="margin: 0.3em;"> <div style="margin: 0.3em;">
{% cache 3600 'organization_html' organization.id MATH_ENGINE %} {% cache 3600 'organization_html' organization.id %}
{{ organization.about|markdown|reference|str|safe }} {{ organization.about|markdown|reference|str|safe }}
{% endcache %} {% endcache %}
</div> </div>

View file

@ -81,7 +81,7 @@
<h3><i class="fa fa-info-circle"></i>{{ _('About') }}</h3> <h3><i class="fa fa-info-circle"></i>{{ _('About') }}</h3>
<div class="sidebox-content"> <div class="sidebox-content">
<div style="margin: 0.3em;"> <div style="margin: 0.3em;">
{% cache 3600 'organization_html' organization.id MATH_ENGINE %} {% cache 3600 'organization_html' organization.id %}
{{ organization.about|markdown|reference|str|safe }} {{ organization.about|markdown|reference|str|safe }}
{% endcache %} {% endcache %}
</div> </div>

View file

@ -380,7 +380,7 @@
</span> </span>
</div> </div>
{% cache 86400 'problem_html' problem.id MATH_ENGINE LANGUAGE_CODE %} {% cache 86400 'problem_html' problem.id LANGUAGE_CODE %}
{{ description|markdown(lazy_load=True)|reference|str|safe }} {{ description|markdown(lazy_load=True)|reference|str|safe }}
{% endcache %} {% endcache %}

View file

@ -141,12 +141,6 @@
<td><label class="inline-header grayed">{{ _('Editor theme') }}:</label></td> <td><label class="inline-header grayed">{{ _('Editor theme') }}:</label></td>
<td><span class="fullwidth">{{ form.ace_theme }}</span></td> <td><span class="fullwidth">{{ form.ace_theme }}</span></td>
</tr> </tr>
{% if has_math_config %}
<tr>
<td><label class="inline-header grayed">{{ _('Math engine') }}:</label></td>
<td><span class="fullwidth">{{ form.math_engine }}</span></td>
</tr>
{% endif %}
</table> </table>
</td> </td>
</tr> </tr>