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

        if not options["original_course"]:
            raise CommandError("--original-course / -o param is required")

        if not options["copy_course"]:
            raise CommandError("--copy-course / -c param is required")

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

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

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

        inserted_activity_rows, inserted_answer_rows, updated_answer_docs = clone_activity_user_course(
            user, copy_course, original_course)
        self.message('Cloned %s activity objects' %
                     len(inserted_activity_rows))
        self.message('Cloned %s answer objects' % len(inserted_answer_rows))
        self.message('Updated %s answer objects' % len(updated_answer_docs))
    def handle(self, *args, **options):
        if not options["user"]:
            raise CommandError("--user / -u param is required")

        if not options["original_course"]:
            raise CommandError("--original-course / -o param is required")

        if not options["copy_course"]:
            raise CommandError("--copy-course / -c param is required")

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

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

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

        inserted_activity_rows, inserted_answer_rows, updated_answer_docs = clone_activity_user_course(user, copy_course, original_course)
        self.message('Cloned %s activity objects' % len(inserted_activity_rows))
        self.message('Cloned %s answer objects' % len(inserted_answer_rows))
        self.message('Updated %s answer objects' % len(updated_answer_docs))
 def handle(self, *args, **options):
     if not options["csv_file"]:
         raise CommandError("--csv / -c param is required")
     csv_path = options["csv_file"]
     if not csv_path.startswith(os.sep):
         csv_path = os.path.join(settings.BASEDIR, csv_path)
     with open(csv_path, 'rb') as csvfile_rb:
         spamreader = csv.reader(csvfile_rb, delimiter=',', quotechar='|')
         for email, old_slug, new_slug in spamreader:
             try:
                 original_course = Course.objects.get(slug=old_slug)
             except Course.DoesNotExist:
                 raise CommandError(u"Course %s does not exist" % old_slug)
             try:
                 copy_course = Course.objects.get(slug=new_slug)
             except Course.DoesNotExist:
                 raise CommandError(u"Course %s does not exist" % new_slug)
             try:
                 user = User.objects.get(email=email)
             except Course.DoesNotExist:
                 raise CommandError(u"User %s does not exist" % email)
             self.message("Cloning activity for: %s" % user)
             clone_activity_user_course(user, copy_course, original_course)
Exemplo n.º 4
0
 def handle(self, *args, **options):
     if not options["csv_file"]:
         raise CommandError("--csv / -c param is required")
     csv_path = options["csv_file"]
     if not csv_path.startswith(os.sep):
         csv_path = os.path.join(settings.BASEDIR, csv_path)
     with open(csv_path, 'rb') as csvfile_rb:
         spamreader = csv.reader(csvfile_rb, delimiter=',', quotechar='|')
         for email, old_slug, new_slug in spamreader:
             try:
                 original_course = Course.objects.get(slug=old_slug)
             except Course.DoesNotExist:
                 raise CommandError(u"Course %s does not exist" % old_slug)
             try:
                 copy_course = Course.objects.get(slug=new_slug)
             except Course.DoesNotExist:
                 raise CommandError(u"Course %s does not exist" % new_slug)
             try:
                 user = User.objects.get(email=email)
             except Course.DoesNotExist:
                 raise CommandError(u"User %s does not exist" % email)
             self.message("Cloning activity for: %s" % user)
             clone_activity_user_course(user, copy_course, original_course)
Exemplo n.º 5
0
def clone_activity_user_course_task(user, course, language):
    activate(language)
    clone_activity_user_course(user, course, force_email=True)
Exemplo n.º 6
0
def clone_activity_user_course_task(user, course):
    clone_activity_user_course(user, course, force_email=True)
Exemplo n.º 7
0
def clone_activity_user_course_task(user, course, language):
    activate(language)
    clone_activity_user_course(user, course, force_email=True)