def delete_rule_from_item(request): from django.http import HttpResponseRedirect from django.conf import settings from gnmvidispine.vs_item import VSItem, VSNotFound i = VSItem(url=settings.VIDISPINE_URL, user=settings.VIDISPINE_USERNAME, passwd=settings.VIDISPINE_PASSWORD, run_as=request.user.username) try: i.populate(request.POST['itemid']) except VSNotFound as e: return render(request, 'gnmlibrarytool/delete_failed.html', {'error': e}) try: shape = i.get_shape(request.POST['delete']) except VSNotFound as e: return render(request, 'gnmlibrarytool/delete_failed.html', {'error': e}) try: shape.delete_storage_rule() except VSNotFound as e: return render(request, 'gnmlibrarytool/delete_failed.html', {'error': e}) return HttpResponseRedirect( request.META.get('HTTP_REFERER') + "#shortcutmv_storage_rule_menu")
def add_rule_to_item(request): from xml.etree.cElementTree import fromstring from gnmvidispine.vs_item import VSItem, VSNotFound from gnmvidispine.vs_storage_rule import VSStorageRuleNew from django.conf import settings from django.http import HttpResponseRedirect newrule = VSStorageRuleNew(url=settings.VIDISPINE_URL,user=settings.VIDISPINE_USERNAME,passwd=settings.VIDISPINE_PASSWORD,run_as=request.user.username) try: newrule.populate_from_xml(fromstring(request.POST['rulexml'])) except VSNotFound as e: return render(request, 'gnmlibrarytool/rule_failed.html', {'error': e}) except SyntaxError as e: return render(request, 'gnmlibrarytool/rule_failed.html', {'error': e}) i = VSItem(url=settings.VIDISPINE_URL,user=settings.VIDISPINE_USERNAME,passwd=settings.VIDISPINE_PASSWORD,run_as=request.user.username) try: i.populate(request.POST['itemid']) except VSNotFound as e: return render(request, 'gnmlibrarytool/rule_failed.html', {'error': e}) try: shape = i.get_shape(request.POST['ruleshape']) except VSNotFound as e: return render(request, 'gnmlibrarytool/rule_failed.html', {'error': e}) try: shape.add_storage_rule(newrule) except VSNotFound as e: return render(request, 'gnmlibrarytool/rule_failed.html', {'error': e}) return HttpResponseRedirect(request.META.get('HTTP_REFERER')+"#shortcutmv_storage_rule_menu")