mirror of
https://github.com/DMOJ/online-judge.git
synced 2024-11-25 16:32:37 +08:00
parent
3ed9ca9379
commit
3923b7580b
@ -21,7 +21,8 @@ class OrganizationForm(ModelForm):
|
||||
|
||||
class OrganizationAdmin(VersionAdmin):
|
||||
readonly_fields = ('creation_date',)
|
||||
fields = ('name', 'slug', 'short_name', 'is_open', 'about', 'slots', 'registrant', 'creation_date', 'admins')
|
||||
fields = ('name', 'slug', 'short_name', 'is_open', 'about', 'logo_override_image', 'slots', 'registrant',
|
||||
'creation_date', 'admins')
|
||||
list_display = ('name', 'short_name', 'is_open', 'slots', 'registrant', 'show_public')
|
||||
prepopulated_fields = {'slug': ('name',)}
|
||||
actions_on_top = True
|
||||
|
@ -86,7 +86,7 @@ class ProblemSubmitForm(ModelForm):
|
||||
class EditOrganizationForm(ModelForm):
|
||||
class Meta:
|
||||
model = Organization
|
||||
fields = ['about', 'admins']
|
||||
fields = ['about', 'logo_override_image', 'admins']
|
||||
widgets = {'admins': Select2MultipleWidget()}
|
||||
if HeavyPreviewPageDownWidget is not None:
|
||||
widgets['about'] = HeavyPreviewPageDownWidget(preview=reverse_lazy('organization_preview'))
|
||||
|
@ -4,4 +4,6 @@ from . import registry
|
||||
|
||||
@registry.filter
|
||||
def camo(url):
|
||||
if camo_client is None:
|
||||
return url
|
||||
return camo_client.image_url(url)
|
||||
|
18
judge/migrations/0095_organization_logo_override.py
Normal file
18
judge/migrations/0095_organization_logo_override.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.1.12 on 2019-10-23 00:11
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('judge', '0094_submissiontestcase_unique_together'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='organization',
|
||||
name='logo_override_image',
|
||||
field=models.CharField(blank=True, default='', help_text='This image will replace the default site logo for users viewing the organization.', max_length=150, verbose_name='Logo override image'),
|
||||
),
|
||||
]
|
@ -44,6 +44,10 @@ class Organization(models.Model):
|
||||
'only applicable to private organizations'))
|
||||
access_code = models.CharField(max_length=7, help_text=_('Student access code'),
|
||||
verbose_name=_('access code'), null=True, blank=True)
|
||||
logo_override_image = models.CharField(verbose_name=_('Logo override image'), default='', max_length=150,
|
||||
blank=True,
|
||||
help_text=_('This image will replace the default site logo for users '
|
||||
'viewing the organization.'))
|
||||
|
||||
def __contains__(self, item):
|
||||
if isinstance(item, int):
|
||||
|
@ -167,6 +167,9 @@ class ContestMixin(object):
|
||||
context['meta_description'] = self.object.summary or metadata[0]
|
||||
context['og_image'] = self.object.og_image or metadata[1]
|
||||
context['has_moss_api_key'] = settings.MOSS_API_KEY is not None
|
||||
context['logo_override_image'] = self.object.logo_override_image
|
||||
if not context['logo_override_image'] and self.object.organizations.count() == 1:
|
||||
context['logo_override_image'] = self.object.organizations.first().logo_override_image
|
||||
|
||||
return context
|
||||
|
||||
|
@ -30,6 +30,11 @@ class OrganizationMixin(object):
|
||||
context_object_name = 'organization'
|
||||
model = Organization
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['logo_override_image'] = self.object.logo_override_image
|
||||
return context
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
try:
|
||||
return super(OrganizationMixin, self).dispatch(request, *args, **kwargs)
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% if request.in_contest and request.participation.contest.logo_override_image %}
|
||||
<img src="{{ request.participation.contest.logo_override_image|camo }}" alt="{{ SITE_NAME }}" height="44" style="border: none">
|
||||
{% elif contest is defined and contest.logo_override_image %}
|
||||
<img src="{{ contest.logo_override_image|camo }}" alt="{{ SITE_NAME }}" height="44" style="border: none">
|
||||
{% elif logo_override_image is defined and logo_override_image %}
|
||||
<img src="{{ logo_override_image|camo }}" alt="{{ SITE_NAME }}" height="44" style="border: none">
|
||||
{% else %}
|
||||
<img src="{{ static('icons/logo.svg') }}" alt="{{ SITE_NAME }}" width="160" height="44"
|
||||
onerror="this.src="{{ static('icons/logo.png') }}"; this.onerror=null" style="border: none">
|
||||
|
Loading…
Reference in New Issue
Block a user