1
+ # coding=utf-8
1
2
from __future__ import absolute_import , unicode_literals
2
3
3
4
import copy
11
12
from django .db import models
12
13
from django .db .models import signals
13
14
from django .db .models .fields import Field
15
+ from django .db .models .signals import class_prepared , post_migrate
14
16
from django .utils .encoding import force_text
15
17
from django .utils .translation import ugettext_lazy as _
16
18
20
22
from concurrency .core import ConcurrencyOptions
21
23
from concurrency .utils import fqn , refetch
22
24
23
- try :
24
- from django .apps import apps
25
-
26
- get_model = apps .get_model
27
- except ImportError :
28
- from django .db .models .loading import get_model
29
-
30
- try :
31
- from django .db .models .signals import class_prepared , post_migrate
32
- except :
33
- from django .db .models .signals import class_prepared , post_syncdb as post_migrate
34
-
35
25
logger = logging .getLogger (__name__ )
36
26
37
27
OFFSET = int (time .mktime ((2000 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 )))
@@ -109,14 +99,6 @@ def __init__(self, *args, **kwargs):
109
99
db_tablespace = db_tablespace ,
110
100
db_column = db_column )
111
101
112
- def deconstruct (self ):
113
- name , path , args , kwargs = super (VersionField , self ).deconstruct ()
114
- kwargs ['default' ] = 1
115
- return name , path , args , kwargs
116
-
117
- def get_default (self ):
118
- return 0
119
-
120
102
def get_internal_type (self ):
121
103
return "BigIntegerField"
122
104
@@ -131,8 +113,8 @@ def formfield(self, **kwargs):
131
113
kwargs ['widget' ] = forms .VersionField .widget
132
114
return super (VersionField , self ).formfield (** kwargs )
133
115
134
- def contribute_to_class (self , cls , name , virtual_only = False ):
135
- super (VersionField , self ).contribute_to_class (cls , name , virtual_only )
116
+ def contribute_to_class (self , cls , * args , ** kwargs ):
117
+ super (VersionField , self ).contribute_to_class (cls , * args , ** kwargs )
136
118
if hasattr (cls , '_concurrencymeta' ) or cls ._meta .abstract :
137
119
return
138
120
setattr (cls , '_concurrencymeta' , ConcurrencyOptions ())
@@ -250,8 +232,8 @@ def __init__(self, *args, **kwargs):
250
232
self ._trigger_exists = False
251
233
super (TriggerVersionField , self ).__init__ (* args , ** kwargs )
252
234
253
- def contribute_to_class (self , cls , name , virtual_only = False ):
254
- super (TriggerVersionField , self ).contribute_to_class (cls , name )
235
+ def contribute_to_class (self , cls , * args , ** kwargs ):
236
+ super (TriggerVersionField , self ).contribute_to_class (cls , * args , ** kwargs )
255
237
if not cls ._meta .abstract or cls ._meta .proxy :
256
238
if self not in _TRIGGERS :
257
239
_TRIGGERS .append (self )
@@ -332,8 +314,8 @@ def filter_fields(instance, field):
332
314
333
315
334
316
class ConditionalVersionField (AutoIncVersionField ):
335
- def contribute_to_class (self , cls , name , virtual_only = False ):
336
- super (ConditionalVersionField , self ).contribute_to_class (cls , name , virtual_only )
317
+ def contribute_to_class (self , cls , * args , ** kwargs ):
318
+ super (ConditionalVersionField , self ).contribute_to_class (cls , * args , ** kwargs )
337
319
signals .post_init .connect (self ._load_model ,
338
320
sender = cls ,
339
321
dispatch_uid = fqn (cls ))
0 commit comments