def get(self, request, *args, **kwargs): if request.GET.has_key('slug'): road_slug = request.GET['slug'] direction = request.GET['direction'] road = Road.objects.get(slug=road_slug) generate_sections(road, direction) messages.success(self.request, 'Successfully created Sections') return simple.redirect_to(request, request.path_info) else: return super(GenerateSections, self).get(request, *args, **kwargs)
def save(self, *args, **kwargs): road = Road.objects.create(name=self.cleaned_data['name']) nodes = self.cleaned_data['node_list'].split('\n') direction = self.cleaned_data['directions'] for cnt, node_name in zip(range(len(nodes)), nodes): node = Node.objects.create( road = road, name = node_name, position = cnt, ) generate_sections(road, direction) return road
def save(self, *args, **kwargs): road = Road.objects.create(name=self.cleaned_data['name']) nodes = self.cleaned_data['node_list'].split('\n') direction = self.cleaned_data['directions'] for cnt, node_name in zip(range(len(nodes)), nodes): node = Node.objects.create( road=road, name=node_name, position=cnt, ) generate_sections(road, direction) return road
def handle_label(self, label, **options): try: road = Road.objects.get(slug=label) except Road.DoesNotExist: return "Road %s not found.\n" % label else: return generate_sections(road, options['direction'])
def handle(self, *labels, **options): if not labels: labels = ['all',] if 'all' in labels: roads = Road.objects.all() result = '' for road in roads: result += generate_sections(road, options['direction']) else: result = super(Command, self).handle(*labels, **options) return result