Skip to content

Commit 04a89de

Browse files
committed
기본값 시간을 모델에서 폼으로
1 parent d5177b3 commit 04a89de

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

judge/admin/problem.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from django.forms import ModelForm
99
from django.utils.html import format_html
1010
from django.utils.translation import ugettext, ungettext, ugettext_lazy as _
11+
from django.utils.timezone import now
1112
from reversion.admin import VersionAdmin
1213

1314
from judge.models import Profile, LanguageLimit, ProblemTranslation, Problem, ProblemClarification
@@ -27,6 +28,7 @@ def __init__(self, *args, **kwargs):
2728
self.fields['change_message'].widget.attrs.update({
2829
'placeholder': ugettext('Describe the changes you made (optional)')
2930
})
31+
self.fields['date'].initial = now
3032

3133
class Meta:
3234
widgets = {

judge/models/problem.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from django.db.models.functions import Coalesce
1212
from django.utils.functional import cached_property
1313
from django.utils.translation import ugettext_lazy as _
14-
from django.utils.timezone import now
1514

1615
from judge.fulltext import SearchQuerySet
1716
from judge.models.profile import Profile
@@ -119,7 +118,7 @@ class Problem(models.Model):
119118
is_public = models.BooleanField(verbose_name=_('publicly visible'), db_index=True, default=False)
120119
is_manually_managed = models.BooleanField(verbose_name=_('manually managed'), db_index=True, default=False,
121120
help_text=_('Whether judges should be allowed to manage data or not'))
122-
date = models.DateTimeField(verbose_name=_('date of publishing'), null=True, blank=True, db_index=True, default=now,
121+
date = models.DateTimeField(verbose_name=_('date of publishing'), null=True, blank=True, db_index=True,
123122
help_text=_("Doesn't have magic ability to auto-publish due to backward compatibility"))
124123
banned_users = models.ManyToManyField(Profile, verbose_name=_('personae non gratae'), blank=True,
125124
help_text=_('Bans the selected users from submitting to this problem'))

0 commit comments

Comments
 (0)