Show More
@@ -122,13 +122,15 b' def ValidReposGroup(edit, old_data):' | |||||
122 | def validate_python(self, value, state): |
|
122 | def validate_python(self, value, state): | |
123 | #TODO WRITE VALIDATIONS |
|
123 | # TODO WRITE VALIDATIONS | |
124 | group_name = value.get('group_name') |
|
124 | group_name = value.get('group_name') | |
125 |
group_parent_id = |
|
125 | group_parent_id = value.get('group_parent_id') | |
126 |
|
126 | |||
127 | # slugify repo group just in case :) |
|
127 | # slugify repo group just in case :) | |
128 | slug = repo_name_slug(group_name) |
|
128 | slug = repo_name_slug(group_name) | |
129 |
|
129 | |||
130 | # check for parent of self |
|
130 | # check for parent of self | |
131 |
|
|
131 | parent_of_self = lambda:(old_data['group_id'] == int(group_parent_id) | |
|
132 | if group_parent_id else False) | |||
|
133 | if edit and parent_of_self(): | |||
132 | e_dict = {'group_parent_id':_('Cannot assign this group ' |
|
134 | e_dict = {'group_parent_id':_('Cannot assign this group ' | |
133 | 'as parent')} |
|
135 | 'as parent')} | |
134 | raise formencode.Invalid('', value, state, |
|
136 | raise formencode.Invalid('', value, state, | |
@@ -136,10 +138,10 b' def ValidReposGroup(edit, old_data):' | |||||
136 |
|
138 | |||
137 | old_gname = None |
|
139 | old_gname = None | |
138 | if edit: |
|
140 | if edit: | |
139 | old_gname = RepoGroup.get( |
|
141 | old_gname = RepoGroup.get(old_data.get('group_id')).group_name | |
140 | old_data.get('group_id')).group_name |
|
|||
141 |
|
142 | |||
142 | if old_gname != group_name or not edit: |
|
143 | if old_gname != group_name or not edit: | |
|
144 | ||||
143 | # check filesystem |
|
145 | # check filesystem | |
144 | gr = RepoGroup.query().filter(RepoGroup.group_name == slug)\ |
|
146 | gr = RepoGroup.query().filter(RepoGroup.group_name == slug)\ | |
145 | .filter(RepoGroup.group_parent_id == group_parent_id).scalar() |
|
147 | .filter(RepoGroup.group_parent_id == group_parent_id).scalar() |
General Comments 0
You need to be logged in to leave comments.
Login now