Эх сурвалжийг харах

[oozie] Enable deleting old workflows from new editor

Romain Rigaux 11 жил өмнө
parent
commit
29498b9bf2

+ 2 - 2
apps/oozie/src/oozie/templates/navigation-bar.mako

@@ -55,8 +55,8 @@
                   <li class="${utils.is_selected(section, 'bundles')}"><a href="${url('oozie:list_bundles')}">${ _('Bundles') }</a></li>
 
                   % if ENABLE_V2.get():
-                    <li class="inline alert alert-warn" style="margin-left:20px; margin-bottom:0px">
-                     ${ _('This is the old editor, please migrate your workflows to the ') } <a style="display:inline" href="${url('oozie:list_editor_workflows')}">${ _('new editor.') }</a>
+                    <li class="inline alert alert-warn" style="margin-left:20px; margin-bottom:0px; margin-top:4px">
+                      ${ _('This is the old editor, please migrate your workflows to the ') } <a style="display:inline" href="${url('oozie:list_editor_workflows')}">${ _('new editor.') }</a>
                     </li>
                   % endif
                 % endif

+ 12 - 7
apps/oozie/src/oozie/views/editor2.py

@@ -38,7 +38,7 @@ from liboozie.submission2 import Submission
 
 from oozie.decorators import check_document_access_permission, check_document_modify_permission
 from oozie.forms import ParameterForm
-from oozie.models import Workflow as OlfWorklow
+from oozie.models import Workflow as OlfWorklow, Job
 from oozie.models2 import Node, Workflow, Coordinator, Bundle, NODES, WORKFLOW_NODE_PROPERTIES, import_workflow_from_hue_3_7,\
     find_dollar_variables, find_dollar_braced_variables
 from oozie.views.editor import edit_workflow as old_edit_workflow 
@@ -125,12 +125,17 @@ def delete_job(request):
   jobs = json.loads(request.POST.get('selection'))
 
   for job in jobs:
-    doc2 = Document2.objects.get(id=job['id'])
-    doc = doc2.doc.get()
-    doc.can_write_or_exception(request.user)
-    
-    doc.delete()
-    doc2.delete()
+    if job.get('uuid'):
+      doc2 = Document2.objects.get(id=job['id'])
+      doc = doc2.doc.get()
+      doc.can_write_or_exception(request.user)
+      
+      doc.delete()
+      doc2.delete()
+    else: # Old workflow version
+      job = Job.objects.can_read_or_exception(request, job['object_id'])
+      Job.objects.can_edit_or_exception(request, job)
+      OlfWorklow.objects.destroy(job, request.fs)      
 
   response = {}
   request.info(_('Document deleted.') if len(jobs) > 1 else _('Document deleted.'))

+ 1 - 0
desktop/core/src/desktop/models.py

@@ -507,6 +507,7 @@ class Document(models.Model):
       'uuid': None,
       'id': self.id,
       'doc1_id': self.id,
+      'object_id': self.object_id,
       'type': str(self.content_type),
       'last_modified': self.last_modified.strftime(UTC_TIME_FORMAT),
       'last_modified_ts': calendar.timegm(self.last_modified.utctimetuple()),