All of lore.kernel.org
 help / color / mirror / Atom feed
* [layerindex-web][PATCH 1/4] admin: add an action to duplicate a branch
@ 2016-11-16  3:18 Paul Eggleton
  2016-11-16  3:18 ` [layerindex-web][PATCH 2/4] utils: fix error in runcmd() if printerr=False Paul Eggleton
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Paul Eggleton @ 2016-11-16  3:18 UTC (permalink / raw)
  To: yocto

Add an action to duplicate a Branch object, along with all of the
LayerBranches (and LayerMaintainers and LayerDependencies) underneath
it.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 layerindex/admin.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/layerindex/admin.py b/layerindex/admin.py
index 7339ce1..f50aae4 100644
--- a/layerindex/admin.py
+++ b/layerindex/admin.py
@@ -17,6 +17,32 @@ class LayerDependencyInline(admin.StackedInline):
 
 class BranchAdmin(CompareVersionAdmin):
     model = Branch
+    actions = ['duplicate']
+
+    def duplicate(self, request, queryset):
+        for branch in queryset:
+            layerbranches = branch.layerbranch_set.all()
+            branch.pk = None
+            branch.name += '-copy'
+            branch.save()
+            for layerbranch in layerbranches:
+                layerbranch_maintainers = layerbranch.layermaintainer_set.all()
+                layerbranch_dependencies = layerbranch.dependencies_set.all()
+                layerbranch.pk = None
+                layerbranch.branch = branch
+                layerbranch.vcs_last_fetch = None
+                layerbranch.vcs_last_rev = ''
+                layerbranch.vcs_last_commit = None
+                layerbranch.save()
+                for layermaintainer in layerbranch_maintainers:
+                    layermaintainer.pk = None
+                    layermaintainer.layerbranch = layerbranch
+                    layermaintainer.save()
+                for layerdependency in layerbranch_dependencies:
+                    layerdependency.pk = None
+                    layerdependency.layerbranch = layerbranch
+                    layerdependency.save()
+    duplicate.short_description = "Duplicate selected Branches"
 
 class LayerItemAdmin(CompareVersionAdmin):
     list_filter = ['status', 'layer_type']
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-16  3:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-16  3:18 [layerindex-web][PATCH 1/4] admin: add an action to duplicate a branch Paul Eggleton
2016-11-16  3:18 ` [layerindex-web][PATCH 2/4] utils: fix error in runcmd() if printerr=False Paul Eggleton
2016-11-16  3:18 ` [layerindex-web][PATCH 3/4] Record and display update logs Paul Eggleton
2016-11-16  3:18 ` [layerindex-web][PATCH 4/4] views: support querying class inheritance Paul Eggleton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.