Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
modelgen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
modelgen
Commits
d24785f9
Commit
d24785f9
authored
Jul 24, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Static values of the form array(array('relation')) are now rewritten to 'relation'.
parent
908f5a80
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
generate.py
generate.py
+24
-0
No files found.
generate.py
View file @
d24785f9
...
@@ -140,15 +140,39 @@ class Model(object):
...
@@ -140,15 +140,39 @@ class Model(object):
self
.
belongs_to
.
append
((
singular
,
self
.
relopts
(
other_model
)))
self
.
belongs_to
.
append
((
singular
,
self
.
relopts
(
other_model
)))
other_model
.
add_has_relation
(
self
)
other_model
.
add_has_relation
(
self
)
def
strip_array
(
self
,
attr
):
array
=
getattr
(
self
,
attr
)
if
len
(
array
)
==
1
:
relation
,
opts
=
array
[
0
]
if
not
len
(
opts
):
return
php_static_var
(
attr
,
php_value
(
relation
))
def
php_has_many
(
self
):
def
php_has_many
(
self
):
stripped
=
self
.
strip_array
(
'has_many'
)
if
stripped
:
return
stripped
if
self
.
has_many
:
if
self
.
has_many
:
return
php_static_array
(
'has_many'
,
self
.
has_many
)
return
php_static_array
(
'has_many'
,
self
.
has_many
)
def
php_has_one
(
self
):
def
php_has_one
(
self
):
stripped
=
self
.
strip_array
(
'has_one'
)
if
stripped
:
return
stripped
if
self
.
has_one
:
if
self
.
has_one
:
return
php_static_array
(
'has_one'
,
self
.
has_one
)
return
php_static_array
(
'has_one'
,
self
.
has_one
)
def
php_belongs_to
(
self
):
def
php_belongs_to
(
self
):
stripped
=
self
.
strip_array
(
'belongs_to'
)
if
stripped
:
return
stripped
if
self
.
belongs_to
:
if
self
.
belongs_to
:
return
php_static_array
(
'belongs_to'
,
self
.
belongs_to
)
return
php_static_array
(
'belongs_to'
,
self
.
belongs_to
)
...
...
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