Skip to content

Commit

Permalink
so smart
Browse files Browse the repository at this point in the history
This reverts commit c6701ee
  • Loading branch information
JasonLovesDoggo committed Jan 6, 2024
1 parent a28e1f5 commit d2f4549
Show file tree
Hide file tree
Showing 203 changed files with 4,085 additions and 15,559 deletions.
6 changes: 5 additions & 1 deletion .ci.settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
STATICFILES_FINDERS += ('compressor.finders.CompressorFinder',)
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

CACHES = {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
}
}

DATABASES = {
'default': {
Expand Down
23 changes: 5 additions & 18 deletions django_ace/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@


class AceWidget(forms.Textarea):
def __init__(
self,
mode=None,
theme=None,
wordwrap=False,
width='100%',
height='300px',
no_ace_media=False,
*args,
**kwargs
):
def __init__(self, mode=None, theme=None, wordwrap=False, width='100%', height='300px',
no_ace_media=False, *args, **kwargs):
self.mode = mode
self.theme = theme
self.wordwrap = wordwrap
Expand Down Expand Up @@ -56,17 +47,13 @@ def render(self, name, value, attrs=None, renderer=None):
if self.wordwrap:
ace_attrs['data-wordwrap'] = 'true'

attrs.update(
style='width: 100%; min-width: 100%; max-width: 100%; resize: none'
)
attrs.update(style='width: 100%; min-width: 100%; max-width: 100%; resize: none')
textarea = super(AceWidget, self).render(name, value, attrs)

html = '<div%s><div></div></div>%s' % (flatatt(ace_attrs), textarea)

# add toolbar
html = (
'<div class="django-ace-editor"><div style="width: 100%%" class="django-ace-toolbar">'
'<a href="./" class="django-ace-max_min"></a></div>%s</div>'
) % html
html = ('<div class="django-ace-editor"><div style="width: 100%%" class="django-ace-toolbar">'
'<a href="./" class="django-ace-max_min"></a></div>%s</div>') % html

return mark_safe(html)
10 changes: 2 additions & 8 deletions dmoj/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
app = Celery('dmoj')

from django.conf import settings # noqa: E402, I202, django must be imported here

app.config_from_object(settings, namespace='CELERY')

if hasattr(settings, 'CELERY_BROKER_URL_SECRET'):
Expand All @@ -24,10 +23,5 @@

@task_failure.connect()
def celery_failure_log(sender, task_id, exception, traceback, *args, **kwargs):
logger.error(
'Celery Task %s: %s on %s',
sender.name,
task_id,
socket.gethostname(), # noqa: G201
exc_info=(type(exception), exception, traceback),
)
logger.error('Celery Task %s: %s on %s', sender.name, task_id, socket.gethostname(), # noqa: G201
exc_info=(type(exception), exception, traceback))
124 changes: 16 additions & 108 deletions dmoj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# Refer to https://dmoj.ca/post/103-point-system-rework
DMOJ_PP_STEP = 0.95
DMOJ_PP_ENTRIES = 100
DMOJ_PP_BONUS_FUNCTION = lambda n: 300 * (1 - 0.997**n) # noqa: E731
DMOJ_PP_BONUS_FUNCTION = lambda n: 300 * (1 - 0.997 ** n) # noqa: E731

ACE_URL = '//cdnjs.cloudflare.com/ajax/libs/ace/1.1.3'
SELECT2_JS_URL = '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js'
Expand All @@ -64,26 +64,11 @@
DMOJ_PROBLEM_MIN_MEMORY_LIMIT = 0 # kilobytes
DMOJ_PROBLEM_MAX_MEMORY_LIMIT = 1048576 # kilobytes
DMOJ_PROBLEM_MIN_PROBLEM_POINTS = 0
DMOJ_PROBLEM_MIN_USER_POINTS_VOTE = (
1 # when voting on problem, minimum point value user can select
)
DMOJ_PROBLEM_MAX_USER_POINTS_VOTE = (
50 # when voting on problem, maximum point value user can select
)
DMOJ_PROBLEM_MIN_USER_POINTS_VOTE = 1 # when voting on problem, minimum point value user can select
DMOJ_PROBLEM_MAX_USER_POINTS_VOTE = 50 # when voting on problem, maximum point value user can select
DMOJ_PROBLEM_HOT_PROBLEM_COUNT = 7

DMOJ_PROBLEM_STATEMENT_DISALLOWED_CHARACTERS = {
'“',
'”',
'‘',
'’',
'−',
'ff',
'fi',
'fl',
'ffi',
'ffl',
}
DMOJ_PROBLEM_STATEMENT_DISALLOWED_CHARACTERS = {'“', '”', '‘', '’', '−', 'ff', 'fi', 'fl', 'ffi', 'ffl'}
DMOJ_RATING_COLORS = True
DMOJ_EMAIL_THROTTLING = (10, 60)

Expand Down Expand Up @@ -173,9 +158,7 @@
INLINE_JQUERY = True
INLINE_FONTAWESOME = True
JQUERY_JS = '//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js'
FONTAWESOME_CSS = (
'//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'
)
FONTAWESOME_CSS = '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'
DMOJ_CANONICAL = ''

# Application definition
Expand Down Expand Up @@ -375,8 +358,7 @@
'trim_blocks': True,
'lstrip_blocks': True,
'translation_engine': 'judge.utils.safe_translations',
'extensions': DEFAULT_EXTENSIONS
+ [
'extensions': DEFAULT_EXTENSIONS + [
'compressor.contrib.jinja2ext.CompressorExtension',
'judge.jinja2.DMOJExtension',
'judge.jinja2.spaceless.SpacelessExtension',
Expand Down Expand Up @@ -428,76 +410,15 @@
]

BLEACH_USER_SAFE_TAGS = [
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'b',
'i',
'strong',
'em',
'tt',
'del',
'kbd',
's',
'abbr',
'cite',
'mark',
'q',
'samp',
'small',
'u',
'var',
'wbr',
'dfn',
'ruby',
'rb',
'rp',
'rt',
'rtc',
'sub',
'sup',
'time',
'data',
'p',
'br',
'pre',
'span',
'div',
'blockquote',
'code',
'hr',
'ul',
'ol',
'li',
'dd',
'dl',
'dt',
'address',
'section',
'details',
'summary',
'table',
'thead',
'tbody',
'tfoot',
'tr',
'th',
'td',
'caption',
'colgroup',
'col',
'tfoot',
'img',
'audio',
'video',
'source',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'b', 'i', 'strong', 'em', 'tt', 'del', 'kbd', 's', 'abbr', 'cite', 'mark', 'q', 'samp', 'small',
'u', 'var', 'wbr', 'dfn', 'ruby', 'rb', 'rp', 'rt', 'rtc', 'sub', 'sup', 'time', 'data',
'p', 'br', 'pre', 'span', 'div', 'blockquote', 'code', 'hr',
'ul', 'ol', 'li', 'dd', 'dl', 'dt', 'address', 'section', 'details', 'summary',
'table', 'thead', 'tbody', 'tfoot', 'tr', 'th', 'td', 'caption', 'colgroup', 'col', 'tfoot',
'img', 'audio', 'video', 'source',
'a',
'style',
'noscript',
'center',
'style', 'noscript', 'center',
]

BLEACH_USER_SAFE_ATTRS = {
Expand All @@ -511,18 +432,7 @@
'td': ['colspan', 'rowspan'],
'th': ['colspan', 'rowspan'],
'audio': ['autoplay', 'controls', 'crossorigin', 'muted', 'loop', 'preload', 'src'],
'video': [
'autoplay',
'controls',
'crossorigin',
'height',
'muted',
'loop',
'poster',
'preload',
'src',
'width',
],
'video': ['autoplay', 'controls', 'crossorigin', 'height', 'muted', 'loop', 'poster', 'preload', 'src', 'width'],
'source': ['src', 'srcset', 'type'],
'li': ['value'],
}
Expand Down Expand Up @@ -621,9 +531,7 @@
EVENT_DAEMON_POLL = '/channels/'
EVENT_DAEMON_KEY = None
EVENT_DAEMON_AMQP_EXCHANGE = 'dmoj-events'
EVENT_DAEMON_SUBMISSION_KEY = (
'6Sdmkx^%pk@GsifDfXcwX*Y7LRF%RGT8vmFpSxFBT$fwS7trc8raWfN#CSfQuKApx&$B#Gh2L7p%W!Ww'
)
EVENT_DAEMON_SUBMISSION_KEY = '6Sdmkx^%pk@GsifDfXcwX*Y7LRF%RGT8vmFpSxFBT$fwS7trc8raWfN#CSfQuKApx&$B#Gh2L7p%W!Ww'

# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
Expand Down
Loading

0 comments on commit d2f4549

Please sign in to comment.