1 from samplebc.bcmagic.utils import report_error, redirect_to_url, autofill
2 from samplebc.samples.models import Sample, Container, Freezer
4 from django.core.exceptions import ObjectDoesNotExist
6 def cmd_move_sample(keyword, text, bcm_mode):
8 FIXME: should live in samples/bcm_cmds.py when this becomes a generic loader
11 # If we received anything other than a sample or container
12 if keyword not in ['s', 'cntr']:
13 return report_error('Keyword "%s" not valid in "%s" bcm_mode' % (keyword, bcm_mode))
17 sampleid = text.split('|')[1]
19 sample = Sample.objects.get(sampleid=sampleid)
20 except ObjectDoesNotExist:
21 return report_error('Sample (%s) does not exist!' % (sampleid))
23 return autofill('id_sampleid', sampleid)
26 elif keyword == 'cntr':
27 cntr_uuid = text.split('|')[1]
30 container = Container.objects.get(uuid=cntr_uuid)
31 except ObjectDoesNotExist, e:
32 return report_error('Container (%s) does not exist!' % (cntr_uuid))
34 return autofill('id_container_id', cntr_uuid)
36 return report_error('The should not happen error occured from cmd_sample_move')