mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
admin: add an action to duplicate a branch
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>
This commit is contained in:
parent
6ff4ed77b4
commit
002b7c1782
|
@ -17,6 +17,32 @@ class LayerDependencyInline(admin.StackedInline):
|
||||||
|
|
||||||
class BranchAdmin(CompareVersionAdmin):
|
class BranchAdmin(CompareVersionAdmin):
|
||||||
model = Branch
|
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):
|
class LayerItemAdmin(CompareVersionAdmin):
|
||||||
list_filter = ['status', 'layer_type']
|
list_filter = ['status', 'layer_type']
|
||||||
|
|
Loading…
Reference in New Issue
Block a user