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
4f151da1
Kaydet (Commit)
4f151da1
authored
Kas 03, 2013
tarafından
Jason Myers
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merging in master
Signed-off-by:
Jason Myers
<
jason@jasonamyers.com
>
üst
6f070273
f40f90d6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
4 deletions
+66
-4
aggregates.py
django/contrib/gis/db/models/sql/aggregates.py
+5
-1
aggregates.py
django/db/models/sql/aggregates.py
+4
-0
models.py
django/forms/models.py
+5
-1
tests.py
tests/admin_widgets/tests.py
+17
-2
tests.py
tests/model_forms/tests.py
+35
-0
No files found.
django/contrib/gis/db/models/sql/aggregates.py
Dosyayı görüntüle @
4f151da1
from
django.db.models.sql.aggregates
import
Aggregate
from
django.db.models.sql
import
aggregates
from
django.db.models.sql.aggregates
import
*
# NOQA
from
django.contrib.gis.db.models.fields
import
GeometryField
from
django.contrib.gis.db.models.fields
import
GeometryField
__all__
=
[
'Collect'
,
'Extent'
,
'Extent3D'
,
'MakeLine'
,
'Union'
]
+
aggregates
.
__all__
class
GeoAggregate
(
Aggregate
):
class
GeoAggregate
(
Aggregate
):
# Default SQL template for spatial aggregates.
# Default SQL template for spatial aggregates.
sql_template
=
'
%(function)
s(
%(field)
s)'
sql_template
=
'
%(function)
s(
%(field)
s)'
...
...
django/db/models/sql/aggregates.py
Dosyayı görüntüle @
4f151da1
...
@@ -5,6 +5,10 @@ import copy
...
@@ -5,6 +5,10 @@ import copy
from
django.db.models.fields
import
IntegerField
,
FloatField
from
django.db.models.fields
import
IntegerField
,
FloatField
__all__
=
[
'Aggregate'
,
'Avg'
,
'Count'
,
'Max'
,
'Min'
,
'StdDev'
,
'Sum'
,
'Variance'
]
# Fake fields used to identify aggregate types in data-conversion operations.
# Fake fields used to identify aggregate types in data-conversion operations.
ordinal_aggregate_field
=
IntegerField
()
ordinal_aggregate_field
=
IntegerField
()
computed_aggregate_field
=
FloatField
()
computed_aggregate_field
=
FloatField
()
...
...
django/forms/models.py
Dosyayı görüntüle @
4f151da1
...
@@ -134,7 +134,11 @@ def model_to_dict(instance, fields=None, exclude=None):
...
@@ -134,7 +134,11 @@ def model_to_dict(instance, fields=None, exclude=None):
data
[
f
.
name
]
=
[]
data
[
f
.
name
]
=
[]
else
:
else
:
# MultipleChoiceWidget needs a list of pks, not object instances.
# MultipleChoiceWidget needs a list of pks, not object instances.
data
[
f
.
name
]
=
list
(
f
.
value_from_object
(
instance
)
.
values_list
(
'pk'
,
flat
=
True
))
qs
=
f
.
value_from_object
(
instance
)
if
qs
.
_result_cache
is
not
None
:
data
[
f
.
name
]
=
[
item
.
pk
for
item
in
qs
]
else
:
data
[
f
.
name
]
=
list
(
qs
.
values_list
(
'pk'
,
flat
=
True
))
else
:
else
:
data
[
f
.
name
]
=
f
.
value_from_object
(
instance
)
data
[
f
.
name
]
=
f
.
value_from_object
(
instance
)
return
data
return
data
...
...
tests/admin_widgets/tests.py
Dosyayı görüntüle @
4f151da1
...
@@ -2,7 +2,12 @@
...
@@ -2,7 +2,12 @@
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
unittest
import
TestCase
from
unittest
import
TestCase
,
skipIf
try
:
import
pytz
except
ImportError
:
pytz
=
None
from
django
import
forms
from
django
import
forms
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -641,6 +646,7 @@ class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests):
...
@@ -641,6 +646,7 @@ class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests):
webdriver_class
=
'selenium.webdriver.ie.webdriver.WebDriver'
webdriver_class
=
'selenium.webdriver.ie.webdriver.WebDriver'
@skipIf
(
pytz
is
None
,
"this test requires pytz"
)
@override_settings
(
TIME_ZONE
=
'Asia/Singapore'
)
@override_settings
(
TIME_ZONE
=
'Asia/Singapore'
)
@override_settings
(
PASSWORD_HASHERS
=
(
'django.contrib.auth.hashers.SHA1PasswordHasher'
,))
@override_settings
(
PASSWORD_HASHERS
=
(
'django.contrib.auth.hashers.SHA1PasswordHasher'
,))
class
DateTimePickerShortcutsSeleniumFirefoxTests
(
AdminSeleniumWebDriverTestCase
):
class
DateTimePickerShortcutsSeleniumFirefoxTests
(
AdminSeleniumWebDriverTestCase
):
...
@@ -660,9 +666,18 @@ class DateTimePickerShortcutsSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase
...
@@ -660,9 +666,18 @@ class DateTimePickerShortcutsSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase
"""
"""
self
.
admin_login
(
username
=
'super'
,
password
=
'secret'
,
login_url
=
'/'
)
self
.
admin_login
(
username
=
'super'
,
password
=
'secret'
,
login_url
=
'/'
)
now
=
datetime
.
now
()
error_margin
=
timedelta
(
seconds
=
10
)
error_margin
=
timedelta
(
seconds
=
10
)
# If we are neighbouring a DST, we add an hour of error margin.
tz
=
pytz
.
timezone
(
'America/Chicago'
)
utc_now
=
datetime
.
now
(
pytz
.
utc
)
tz_yesterday
=
(
utc_now
-
timedelta
(
days
=
1
))
.
astimezone
(
tz
)
.
tzname
()
tz_tomorrow
=
(
utc_now
+
timedelta
(
days
=
1
))
.
astimezone
(
tz
)
.
tzname
()
if
tz_yesterday
!=
tz_tomorrow
:
error_margin
+=
timedelta
(
hours
=
1
)
now
=
datetime
.
now
()
self
.
selenium
.
get
(
'
%
s
%
s'
%
(
self
.
live_server_url
,
self
.
selenium
.
get
(
'
%
s
%
s'
%
(
self
.
live_server_url
,
'/admin_widgets/member/add/'
))
'/admin_widgets/member/add/'
))
...
...
tests/model_forms/tests.py
Dosyayı görüntüle @
4f151da1
...
@@ -828,6 +828,41 @@ class ModelToDictTests(TestCase):
...
@@ -828,6 +828,41 @@ class ModelToDictTests(TestCase):
# Ensure many-to-many relation appears as a list
# Ensure many-to-many relation appears as a list
self
.
assertIsInstance
(
d
[
'categories'
],
list
)
self
.
assertIsInstance
(
d
[
'categories'
],
list
)
def
test_reuse_prefetched
(
self
):
# model_to_dict should not hit the database if it can reuse
# the data populated by prefetch_related.
categories
=
[
Category
(
name
=
'TestName1'
,
slug
=
'TestName1'
,
url
=
'url1'
),
Category
(
name
=
'TestName2'
,
slug
=
'TestName2'
,
url
=
'url2'
),
Category
(
name
=
'TestName3'
,
slug
=
'TestName3'
,
url
=
'url3'
)
]
for
c
in
categories
:
c
.
save
()
writer
=
Writer
(
name
=
'Test writer'
)
writer
.
save
()
art
=
Article
(
headline
=
'Test article'
,
slug
=
'test-article'
,
pub_date
=
datetime
.
date
(
1988
,
1
,
4
),
writer
=
writer
,
article
=
'Hello.'
)
art
.
save
()
for
c
in
categories
:
art
.
categories
.
add
(
c
)
art
=
Article
.
objects
.
prefetch_related
(
'categories'
)
.
get
(
pk
=
art
.
pk
)
with
self
.
assertNumQueries
(
0
):
d
=
model_to_dict
(
art
)
#Ensure all many-to-many categories appear in model_to_dict
for
c
in
categories
:
self
.
assertIn
(
c
.
pk
,
d
[
'categories'
])
#Ensure many-to-many relation appears as a list
self
.
assertIsInstance
(
d
[
'categories'
],
list
)
class
OldFormForXTests
(
TestCase
):
class
OldFormForXTests
(
TestCase
):
def
test_base_form
(
self
):
def
test_base_form
(
self
):
...
...
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