Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
d5bac7e4
Kaydet (Commit)
d5bac7e4
authored
Eyl 04, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25353 -- Changed LogEntry.action_time to a "date created".
üst
e133b559
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
5 deletions
+48
-5
0002_logentry_remove_auto_add.py
...contrib/admin/migrations/0002_logentry_remove_auto_add.py
+25
-0
models.py
django/contrib/admin/models.py
+13
-5
tests.py
tests/admin_views/tests.py
+10
-0
No files found.
django/contrib/admin/migrations/0002_logentry_remove_auto_add.py
0 → 100644
Dosyayı görüntüle @
d5bac7e4
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
from
django.utils
import
timezone
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'admin'
,
'0001_initial'
),
]
# No database changes; removes auto_add and adds default/editable.
operations
=
[
migrations
.
AlterField
(
model_name
=
'logentry'
,
name
=
'action_time'
,
field
=
models
.
DateTimeField
(
verbose_name
=
'action time'
,
default
=
timezone
.
now
,
editable
=
False
,
),
),
]
django/contrib/admin/models.py
Dosyayı görüntüle @
d5bac7e4
...
...
@@ -5,6 +5,7 @@ from django.contrib.admin.utils import quote
from
django.contrib.contenttypes.models
import
ContentType
from
django.core.urlresolvers
import
NoReverseMatch
,
reverse
from
django.db
import
models
from
django.utils
import
timezone
from
django.utils.encoding
import
python_2_unicode_compatible
,
smart_text
from
django.utils.translation
import
ugettext
,
ugettext_lazy
as
_
...
...
@@ -17,16 +18,23 @@ class LogEntryManager(models.Manager):
use_in_migrations
=
True
def
log_action
(
self
,
user_id
,
content_type_id
,
object_id
,
object_repr
,
action_flag
,
change_message
=
''
):
e
=
self
.
model
(
None
,
None
,
user_id
,
content_type_id
,
smart_text
(
object_id
),
object_repr
[:
200
],
action_flag
,
change_message
self
.
model
.
objects
.
create
(
user_id
=
user_id
,
content_type_id
=
content_type_id
,
object_id
=
smart_text
(
object_id
),
object_repr
=
object_repr
[:
200
],
action_flag
=
action_flag
,
change_message
=
change_message
,
)
e
.
save
()
@python_2_unicode_compatible
class
LogEntry
(
models
.
Model
):
action_time
=
models
.
DateTimeField
(
_
(
'action time'
),
auto_now
=
True
)
action_time
=
models
.
DateTimeField
(
_
(
'action time'
),
default
=
timezone
.
now
,
editable
=
False
,
)
user
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
models
.
CASCADE
,
...
...
tests/admin_views/tests.py
Dosyayı görüntüle @
d5bac7e4
...
...
@@ -2405,6 +2405,16 @@ class AdminViewStringPrimaryKeyTest(TestCase):
edited_obj
=
logentry
.
get_edited_object
()
self
.
assertEqual
(
logentry
.
object_id
,
str
(
edited_obj
.
pk
))
def
test_logentry_save
(
self
):
""""
LogEntry.action_time is a timestamp of the date when the entry was
created. It shouldn't be updated on a subsequent save().
"""
logentry
=
LogEntry
.
objects
.
get
(
content_type__model__iexact
=
"modelwithstringprimarykey"
)
action_time
=
logentry
.
action_time
logentry
.
save
()
self
.
assertEqual
(
logentry
.
action_time
,
action_time
)
def
test_deleteconfirmation_link
(
self
):
"The link from the delete confirmation page referring back to the changeform of the object should be quoted"
response
=
self
.
client
.
get
(
reverse
(
'admin:admin_views_modelwithstringprimarykey_delete'
,
args
=
(
quote
(
self
.
pk
),)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment