Ejemplo n.º 1
0
    def handle(self, *args, **options):
        if not options["course"]:
            raise CommandError("--course / -c param is required")

        try:
            course = Course.objects.get(pk=options["course"])
        except Course.DoesNotExist:
            raise CommandError(u"Course %s does not exist" % options["course"])

        objs, file_path = clone_course(course, request=None)
        self.message("Created %s objects succesfully" % len(objs))
        self.message("The new course is pk=%s" % objs[0].pk)
        self.message("You have a trace in %s" % file_path)
Ejemplo n.º 2
0
    def handle(self, *args, **options):
        if not options["course"]:
            raise CommandError("--course / -c param is required")

        try:
            course = Course.objects.get(pk=options["course"])
        except Course.DoesNotExist:
            raise CommandError(u"Course %s does not exist" % options["course"])

        objs, file_path = clone_course(course, request=None)
        self.message("Created %s objects succesfully" % len(objs))
        self.message("The new course is pk=%s" % objs[0].pk)
        self.message("You have a trace in %s" % file_path)
Ejemplo n.º 3
0
 def clone_course(self, request, object_id, form_url='', extra_context=None, action='clone'):
     course = self.get_object(request, unquote(object_id))
     if request.method == 'POST':
         objs, file_name = clone_course(course, request)
         messages.info(request, _('Created %s objects succesfully') % len(objs))
         messages.info(request, _('You have a trace in %s') % file_name)
         return HttpResponseRedirect(reverse('admin:courses_course_change', args=(objs[0].pk,)))
     opts = self.model._meta
     return render_to_response('admin/courses/course/clone_form.html',
                               {'original': course,
                                'app_label': opts.app_label,
                                'opts': opts,
                                'title': _('Clone Course')},
                               context_instance=RequestContext(request))
Ejemplo n.º 4
0
 def clone_course(self, request, object_id, form_url='', extra_context=None, action='clone'):
     course = self.get_object(request, unquote(object_id))
     if request.method == 'POST':
         objs, file_name = clone_course(course, request)
         messages.info(request, ugettext('Created %s objects succesfully') % len(objs))
         messages.info(request, ugettext('You have a trace in %s') % file_name)
         return HttpResponseRedirect(reverse('admin:courses_course_change', args=(objs[0].pk,)))
     opts = self.model._meta
     return render_to_response('admin/courses/course/clone_form.html',
                               {'original': course,
                                'app_label': opts.app_label,
                                'opts': opts,
                                'title': ugettext('Clone Course')},
                               context_instance=RequestContext(request))