本文整理汇总了Python中patchwork.models.Bundle.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Bundle.delete方法的具体用法?Python Bundle.delete怎么用?Python Bundle.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类patchwork.models.Bundle
的用法示例。
在下文中一共展示了Bundle.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BundleTestBase
# 需要导入模块: from patchwork.models import Bundle [as 别名]
# 或者: from patchwork.models.Bundle import delete [as 别名]
class BundleTestBase(TestCase):
def setUp(self, patch_count=3):
patch_names = ["testpatch%d" % (i) for i in range(1, patch_count + 1)]
self.user = create_user()
self.client.login(username=self.user.username, password=self.user.username)
defaults.project.save()
self.bundle = Bundle(owner=self.user, project=defaults.project, name="testbundle")
self.bundle.save()
self.patches = []
for patch_name in patch_names:
patch = Patch(
project=defaults.project,
msgid=patch_name,
name=patch_name,
submitter=Person.objects.get(user=self.user),
content="",
)
patch.save()
self.patches.append(patch)
def tearDown(self):
for patch in self.patches:
patch.delete()
self.bundle.delete()
self.user.delete()
示例2: setbundle
# 需要导入模块: from patchwork.models import Bundle [as 别名]
# 或者: from patchwork.models.Bundle import delete [as 别名]
def setbundle(request):
bundle = None
if request.method == 'POST':
action = request.POST.get('action', None)
if action is None:
pass
elif action == 'create':
project = get_object_or_404(Project,
id=request.POST.get('project'))
bundle = Bundle(owner=request.user, project=project,
name=request.POST['name'])
bundle.save()
patch_id = request.POST.get('patch_id', None)
if patch_id:
patch = get_object_or_404(Patch, id=patch_id)
bundle.append_patch(patch)
bundle.save()
elif action == 'add':
bundle = get_object_or_404(Bundle,
owner=request.user,
id=request.POST['id'])
bundle.save()
patch_id = request.get('patch_id', None)
if patch_id:
patch_ids = patch_id
else:
patch_ids = get_patch_ids(request.POST)
for patch_id in patch_ids:
patch = Patch.objects.get(id=patch_id)
bundle.append_patch(patch)
bundle.save()
elif action == 'delete':
try:
bundle = Bundle.objects.get(owner=request.user,
id=request.POST['id'])
bundle.delete()
except Bundle.DoesNotExist:
pass
bundle = None
else:
bundle = get_object_or_404(Bundle, owner=request.user,
id=request.POST['bundle_id'])
if bundle:
return HttpResponseRedirect(
django.core.urlresolvers.reverse(
'bundle-detail',
kwargs={'bundle_id': bundle.id}
)
)
else:
return HttpResponseRedirect(
django.core.urlresolvers.reverse('user-bundles')
)
示例3: BundleTestBase
# 需要导入模块: from patchwork.models import Bundle [as 别名]
# 或者: from patchwork.models.Bundle import delete [as 别名]
class BundleTestBase(TestCase):
fixtures = ['default_states']
def setUp(self, patch_count=3):
self.user = create_user()
self.client.login(username=self.user.username,
password=self.user.username)
defaults.project.save()
self.bundle = Bundle(owner=self.user, project=defaults.project,
name='testbundle')
self.bundle.save()
self.patches = create_patches(patch_count)
def tearDown(self):
for patch in self.patches:
patch.delete()
self.bundle.delete()
self.user.delete()
示例4: setbundle
# 需要导入模块: from patchwork.models import Bundle [as 别名]
# 或者: from patchwork.models.Bundle import delete [as 别名]
def setbundle(request):
context = PatchworkRequestContext(request)
bundle = None
if request.method == 'POST':
action = request.POST.get('action', None)
if action is None:
pass
elif action == 'create':
project = get_object_or_404(Project,
id = request.POST.get('project'))
bundle = Bundle(owner = request.user, project = project,
name = request.POST['name'])
bundle.save()
patch_id = request.POST.get('patch_id', None)
if patch_id:
patch = get_object_or_404(Patch, id = patch_id)
try:
bundle.append_patch(patch)
except Exception:
pass
bundle.save()
elif action == 'add':
bundle = get_object_or_404(Bundle,
owner = request.user, id = request.POST['id'])
bundle.save()
patch_id = request.get('patch_id', None)
if patch_id:
patch_ids = patch_id
else:
patch_ids = get_patch_ids(request.POST)
for id in patch_ids:
try:
patch = Patch.objects.get(id = id)
bundle.append_patch(patch)
except:
pass
bundle.save()
elif action == 'delete':
try:
bundle = Bundle.objects.get(owner = request.user,
id = request.POST['id'])
bundle.delete()
except Exception:
pass
bundle = None
else:
bundle = get_object_or_404(Bundle, owner = request.user,
id = request.POST['bundle_id'])
if 'error' in context:
pass
if bundle:
return HttpResponseRedirect(
django.core.urlresolvers.reverse(
'patchwork.views.bundle.bundle',
kwargs = {'bundle_id': bundle.id}
)
)
else:
return HttpResponseRedirect(
django.core.urlresolvers.reverse(
'patchwork.views.bundle.list')
)