|
Lines 44-53
Link Here
|
| 44 |
from univention.admin.handlers.computers import domaincontroller_master |
44 |
from univention.admin.handlers.computers import domaincontroller_master |
| 45 |
from univention.admin.handlers.computers import domaincontroller_backup |
45 |
from univention.admin.handlers.computers import domaincontroller_backup |
| 46 |
|
46 |
|
| 47 |
|
|
|
| 48 |
# local application |
47 |
# local application |
| 49 |
from constants import COMPONENT_BASE, COMP_PARAMS, STATUS_ICONS, DEFAULT_ICON, PUT_SUCCESS, PUT_PROCESSING_ERROR |
48 |
from constants import COMPONENT_BASE, COMP_PARAMS, STATUS_ICONS, DEFAULT_ICON, PUT_SUCCESS, PUT_PROCESSING_ERROR |
| 50 |
|
49 |
|
|
|
50 |
_ucr = univention.config_registry.ConfigRegistry() |
| 51 |
_ucr.load() |
| 52 |
|
| 51 |
def rename_app(old_id, new_id, component_manager, package_manager): |
53 |
def rename_app(old_id, new_id, component_manager, package_manager): |
| 52 |
from univention.management.console.modules.appcenter.app_center import Application |
54 |
from univention.management.console.modules.appcenter.app_center import Application |
| 53 |
app = Application.find(old_id) |
55 |
app = Application.find(old_id) |
|
Lines 133-139
Link Here
|
| 133 |
def component_registered(component_id, ucr): |
135 |
def component_registered(component_id, ucr): |
| 134 |
''' Checks if a component is registered (enabled or disabled). |
136 |
''' Checks if a component is registered (enabled or disabled). |
| 135 |
Moved outside of ComponentManager to avoid dependencies for |
137 |
Moved outside of ComponentManager to avoid dependencies for |
| 136 |
UniventionUpdater when just using Application.all() ''' |
138 |
UniventionUpdater''' |
| 137 |
return '%s/%s' % (COMPONENT_BASE, component_id) in ucr |
139 |
return '%s/%s' % (COMPONENT_BASE, component_id) in ucr |
| 138 |
|
140 |
|
| 139 |
def component_current(component_id, ucr): |
141 |
def component_current(component_id, ucr): |
|
Lines 273-282
Link Here
|
| 273 |
def is_registered(self, component_id): |
275 |
def is_registered(self, component_id): |
| 274 |
return component_registered(component_id, self.ucr) |
276 |
return component_registered(component_id, self.ucr) |
| 275 |
|
277 |
|
| 276 |
def put_app(self, app, super_ucr=None): |
278 |
def put_app_new_format(self, app, super_ucr=None): |
| 277 |
if super_ucr is None: |
279 |
if super_ucr is None: |
| 278 |
with set_save_commit_load(self.ucr) as super_ucr: |
280 |
with set_save_commit_load(self.ucr) as super_ucr: |
| 279 |
return self.put_app(app, super_ucr) |
281 |
return self.put_app(app, super_ucr) |
|
|
282 |
ucr_var = app.repository_ucr_var() |
| 283 |
if ucr_var: |
| 284 |
super_ucr.set_registry_var(ucr_var, 'enabled') |
| 285 |
|
| 286 |
def remove_app_new_format(self, app, super_ucr=None): |
| 287 |
if super_ucr is None: |
| 288 |
with set_save_commit_load(self.ucr) as super_ucr: |
| 289 |
return self.remove_app(app, super_ucr) |
| 290 |
ucr_var = app.repository_ucr_var() |
| 291 |
if ucr_var: |
| 292 |
super_ucr.set_registry_var(ucr_var, '') |
| 293 |
|
| 294 |
def put_app_old_format(self, app, super_ucr=None): |
| 295 |
if super_ucr is None: |
| 296 |
with set_save_commit_load(self.ucr) as super_ucr: |
| 297 |
return self.put_app(app, super_ucr) |
| 280 |
app_data = { |
298 |
app_data = { |
| 281 |
'server' : app.get_server(), |
299 |
'server' : app.get_server(), |
| 282 |
'prefix' : '', |
300 |
'prefix' : '', |
|
Lines 296-307
Link Here
|
| 296 |
app_data['version'] = 'current' |
314 |
app_data['version'] = 'current' |
| 297 |
self.put(app_data, super_ucr) |
315 |
self.put(app_data, super_ucr) |
| 298 |
|
316 |
|
| 299 |
def remove_app(self, app, super_ucr=None): |
317 |
def remove_app_old_format(self, app, super_ucr): |
| 300 |
if super_ucr is None: |
318 |
if super_ucr is None: |
| 301 |
with set_save_commit_load(self.ucr) as super_ucr: |
319 |
with set_save_commit_load(self.ucr) as super_ucr: |
| 302 |
return self.remove_app(app, super_ucr) |
320 |
return self.remove_app(app, super_ucr) |
| 303 |
self._remove(app.component_id, super_ucr) |
321 |
self._remove(app.component_id, super_ucr) |
| 304 |
|
322 |
|
|
|
323 |
if _ucr.is_true('repository/app_center/new_format', True): |
| 324 |
put_app = put_app_new_format |
| 325 |
remove_app = remove_app_new_format |
| 326 |
else: |
| 327 |
put_app = put_app_old_format |
| 328 |
remove_app = remove_app_old_format |
| 329 |
|
| 305 |
def put(self, data, super_ucr): |
330 |
def put(self, data, super_ucr): |
| 306 |
""" Does the real work of writing one component definition back. |
331 |
""" Does the real work of writing one component definition back. |
| 307 |
Will be called for each element in the request array of |
332 |
Will be called for each element in the request array of |
|
Lines 360-365
Link Here
|
| 360 |
self.put({'name' : component_id, 'version' : ''}, super_ucr) |
385 |
self.put({'name' : component_id, 'version' : ''}, super_ucr) |
| 361 |
return super_ucr.changed() |
386 |
return super_ucr.changed() |
| 362 |
|
387 |
|
|
|
388 |
def enable_app(self, app, super_ucr=None): |
| 389 |
if super_ucr is None: |
| 390 |
with set_save_commit_load(self.ucr) as super_ucr: |
| 391 |
return self.enable_app(app, super_ucr) |
| 392 |
if self.ucr.is_true('repository/app_center/new_format', True): |
| 393 |
ucr_var = app.repository_ucr_var() |
| 394 |
if ucr_var: |
| 395 |
super_ucr.set_registry_var(ucr_var, 'enabled') |
| 396 |
else: |
| 397 |
self.currentify(app.component_id, super_ucr) |
| 398 |
return super_ucr.changed() |
| 399 |
|
| 400 |
def disable_app(self, app, super_ucr=None): |
| 401 |
if super_ucr is None: |
| 402 |
with set_save_commit_load(self.ucr) as super_ucr: |
| 403 |
return self.disable_app(app, super_ucr) |
| 404 |
if self.ucr.is_true('repository/app_center/new_format', True): |
| 405 |
ucr_var = app.repository_ucr_var() |
| 406 |
if ucr_var: |
| 407 |
super_ucr.set_registry_var(ucr_var, 'disabled') |
| 408 |
else: |
| 409 |
self.uncurrentify(app.component_id, super_ucr) |
| 410 |
return super_ucr.changed() |
| 411 |
|
| 363 |
def _remove(self, component_id, super_ucr): |
412 |
def _remove(self, component_id, super_ucr): |
| 364 |
named_component_base = '%s/%s' % (COMPONENT_BASE, component_id) |
413 |
named_component_base = '%s/%s' % (COMPONENT_BASE, component_id) |
| 365 |
for var in COMP_PARAMS: |
414 |
for var in COMP_PARAMS: |