2157 |
2157 |
assert len(ods_sheet.findall('.//{%s}table-row' % ods.NS['table'])) == 311
|
2158 |
2158 |
|
2159 |
2159 |
|
|
2160 |
def test_api_custom_view_access(pub, local_user):
|
|
2161 |
Role.wipe()
|
|
2162 |
role = Role(name='test')
|
|
2163 |
role.store()
|
|
2164 |
local_user.roles = [role.id]
|
|
2165 |
local_user.store()
|
|
2166 |
|
|
2167 |
FormDef.wipe()
|
|
2168 |
formdef = FormDef()
|
|
2169 |
formdef.name = 'test'
|
|
2170 |
formdef.workflow_roles = {'_receiver': role.id}
|
|
2171 |
formdef.fields = [fields.StringField(id='0', label='foobar', varname='foobar')]
|
|
2172 |
formdef.geolocations = {'base': 'Location'}
|
|
2173 |
formdef.store()
|
|
2174 |
|
|
2175 |
carddef = CardDef()
|
|
2176 |
carddef.name = 'test'
|
|
2177 |
carddef.fields = [fields.StringField(id='0', label='foobar', varname='foo')]
|
|
2178 |
carddef.workflow_roles = {'_viewer': role.id}
|
|
2179 |
carddef.digest_template = 'bla {{ form_var_foo }} xxx'
|
|
2180 |
carddef.geolocations = {'base': 'Location'}
|
|
2181 |
carddef.store()
|
|
2182 |
|
|
2183 |
pub.custom_view_class.wipe()
|
|
2184 |
custom_view = pub.custom_view_class()
|
|
2185 |
custom_view.title = 'shared formdef custom view'
|
|
2186 |
custom_view.formdef = formdef
|
|
2187 |
custom_view.columns = {'list': [{'id': '0'}]}
|
|
2188 |
custom_view.filters = {}
|
|
2189 |
custom_view.visibility = 'any'
|
|
2190 |
custom_view.store()
|
|
2191 |
|
|
2192 |
custom_view = pub.custom_view_class()
|
|
2193 |
custom_view.title = 'private formdef custom view'
|
|
2194 |
custom_view.formdef = formdef
|
|
2195 |
custom_view.columns = {'list': [{'id': '0'}]}
|
|
2196 |
custom_view.filters = {}
|
|
2197 |
custom_view.visibility = 'owner'
|
|
2198 |
custom_view.user = local_user
|
|
2199 |
custom_view.store()
|
|
2200 |
|
|
2201 |
custom_view = pub.custom_view_class()
|
|
2202 |
custom_view.title = 'shared carddef custom view'
|
|
2203 |
custom_view.formdef = carddef
|
|
2204 |
custom_view.columns = {'list': [{'id': '0'}]}
|
|
2205 |
custom_view.filters = {}
|
|
2206 |
custom_view.visibility = 'any'
|
|
2207 |
custom_view.store()
|
|
2208 |
|
|
2209 |
custom_view = pub.custom_view_class()
|
|
2210 |
custom_view.title = 'private carddef custom view'
|
|
2211 |
custom_view.formdef = carddef
|
|
2212 |
custom_view.columns = {'list': [{'id': '0'}]}
|
|
2213 |
custom_view.filters = {}
|
|
2214 |
custom_view.visibility = 'owner'
|
|
2215 |
custom_view.user = local_user
|
|
2216 |
custom_view.store()
|
|
2217 |
|
|
2218 |
custom_view = pub.custom_view_class()
|
|
2219 |
custom_view.title = 'datasource carddef custom view'
|
|
2220 |
custom_view.formdef = carddef
|
|
2221 |
custom_view.columns = {'list': [{'id': '0'}]}
|
|
2222 |
custom_view.filters = {}
|
|
2223 |
custom_view.visibility = 'datasource'
|
|
2224 |
custom_view.store()
|
|
2225 |
|
|
2226 |
get_app(pub).get(sign_uri('/api/forms/test/list/shared-formdef-custom-view', user=local_user), status=200)
|
|
2227 |
get_app(pub).get(sign_uri('/api/forms/test/ods/shared-formdef-custom-view', user=local_user), status=200)
|
|
2228 |
get_app(pub).get(sign_uri('/api/forms/test/geojson/shared-formdef-custom-view', user=local_user), status=200)
|
|
2229 |
get_app(pub).get(sign_uri('/api/forms/test/list/private-formdef-custom-view', user=local_user), status=404)
|
|
2230 |
get_app(pub).get(sign_uri('/api/forms/test/ods/private-formdef-custom-view', user=local_user), status=404)
|
|
2231 |
get_app(pub).get(sign_uri('/api/forms/test/geojson/private-formdef-custom-view', user=local_user), status=404)
|
|
2232 |
|
|
2233 |
get_app(pub).get(sign_uri('/api/cards/test/list/shared-carddef-custom-view', user=local_user), status=200)
|
|
2234 |
get_app(pub).get(sign_uri('/api/cards/test/ods/shared-carddef-custom-view', user=local_user), status=200)
|
|
2235 |
get_app(pub).get(sign_uri('/api/cards/test/geojson/shared-carddef-custom-view', user=local_user), status=200)
|
|
2236 |
get_app(pub).get(sign_uri('/api/cards/test/list/private-carddef-custom-view', user=local_user), status=404)
|
|
2237 |
get_app(pub).get(sign_uri('/api/cards/test/ods/private-carddef-custom-view', user=local_user), status=404)
|
|
2238 |
get_app(pub).get(sign_uri('/api/cards/test/geojson/private-carddef-custom-view', user=local_user), status=404)
|
|
2239 |
get_app(pub).get(sign_uri('/api/cards/test/list/datasource-carddef-custom-view', user=local_user), status=200)
|
|
2240 |
get_app(pub).get(sign_uri('/api/cards/test/ods/datasource-carddef-custom-view', user=local_user), status=200)
|
|
2241 |
get_app(pub).get(sign_uri('/api/cards/test/geojson/datasource-carddef-custom-view', user=local_user), status=200)
|
|
2242 |
|
|
2243 |
|
2160 |
2244 |
def test_api_list_formdata_custom_view(pub, local_user):
|
2161 |
2245 |
Role.wipe()
|
2162 |
2246 |
role = Role(name='test')
|
... | ... | |
3228 |
3312 |
local_user.roles = [role.id]
|
3229 |
3313 |
local_user.store()
|
3230 |
3314 |
|
|
3315 |
CardDef.wipe()
|
3231 |
3316 |
carddef = CardDef()
|
3232 |
3317 |
carddef.name = 'test'
|
3233 |
3318 |
carddef.fields = [fields.StringField(id='0', label='foobar', varname='foo')]
|
... | ... | |
3235 |
3320 |
carddef.digest_template = 'bla {{ form_var_foo }} xxx'
|
3236 |
3321 |
carddef.store()
|
3237 |
3322 |
|
|
3323 |
carddef.data_class().wipe()
|
3238 |
3324 |
formdata = carddef.data_class()()
|
3239 |
3325 |
formdata.data = {'0': 'blah'}
|
3240 |
3326 |
formdata.just_created()
|