Esempio n. 1
0
    def setUp(self):
        super(TestWikiAccess, self).setUp()

        self.course_310b = CourseFactory.create(org="org", number="310b", display_name="Course")
        self.course_310b_staff = self.create_staff_for_course(self.course_310b)
        self.course_310b2 = CourseFactory.create(org="org", number="310b_", display_name="Course")
        self.course_310b2_staff = self.create_staff_for_course(self.course_310b2)

        self.wiki_310b = self.create_urlpath(self.wiki, course_wiki_slug(self.course_310b))
        self.wiki_310b2 = self.create_urlpath(self.wiki, course_wiki_slug(self.course_310b2))
Esempio n. 2
0
    def setUp(self):
        super(TestWikiAccess, self).setUp()

        self.course_310b = CourseFactory.create(org='org', number='310b', display_name='Course')
        self.course_310b_staff = self.create_staff_for_course(self.course_310b)
        self.course_310b2 = CourseFactory.create(org='org', number='310b_', display_name='Course')
        self.course_310b2_staff = self.create_staff_for_course(self.course_310b2)

        self.wiki_310b = self.create_urlpath(self.wiki, course_wiki_slug(self.course_310b))
        self.wiki_310b2 = self.create_urlpath(self.wiki, course_wiki_slug(self.course_310b2))
Esempio n. 3
0
    def setUp(self):
        super(TestWikiAccess, self).setUp()

        self.course_310b = CourseFactory.create(org='org', number='310b', display_name='Course')
        self.course_310b_staff = self.create_staff_for_course(self.course_310b)
        self.course_310b2 = CourseFactory.create(org='org', number='310b_', display_name='Course')
        self.course_310b2_staff = self.create_staff_for_course(self.course_310b2)

        self.wiki_310b = self.create_urlpath(self.wiki, course_wiki_slug(self.course_310b))
        self.wiki_310b2 = self.create_urlpath(self.wiki, course_wiki_slug(self.course_310b2))
Esempio n. 4
0
    def setUp(self):
        super(TestWikiAccess, self).setUp()

        self.course_310b = CourseFactory.create(org='org', number='310b', display_name='Course')
        self.course_310b_staff = [InstructorFactory(course=self.course_310b.location), StaffFactory(course=self.course_310b.location)]
        self.course_310b_ = CourseFactory.create(org='org', number='310b_', display_name='Course')
        self.course_310b__staff = [InstructorFactory(course=self.course_310b_.location), StaffFactory(course=self.course_310b_.location)]

        self.wiki_310b = self.create_urlpath(self.wiki, course_wiki_slug(self.course_310b))
        self.wiki_310b_ = self.create_urlpath(self.wiki, course_wiki_slug(self.course_310b_))
    def handle(self, *args, **options):
        if len(args) == 0:
            raise CommandError("Define at least one course_id argument")

        for course_key_string in args:
            course_key = CourseKey.from_string(course_key_string)
            course = modulestore().get_course(course_key)
            slug = course_wiki_slug(course)

            # Note that this requires one request per argument and could be optimised
            urlpaths = wiki.models.urlpath.URLPath.objects.select_related("article").filter(slug=slug)
            if not urlpaths:
                self.stdout.write(
                    "---- Wiki article '{}' for course {} could not be found\n".format(slug, course_key_string)
                )
                continue
            for urlpath in urlpaths:
                urlpath.article.group_write = False
                urlpath.article.other_write = False
                urlpath.article.save()
                urlpath_descendants = urlpath.article.descendant_objects()
                (wiki.models.article.Article.objects.filter(urlpath__in=urlpath_descendants)
                                                    .update(group_write=False, other_write=False))
                self.stdout.write(
                    "++++ Write permissions removed from wiki '{}' for course {}\n".format(slug, course_key_string)
                )
Esempio n. 6
0
    def setUp(self):
        super(TestWikiAccessForNumericalCourseNumber, self).setUp()

        self.course_200 = CourseFactory.create(org='org', number='200', display_name='Course')
        self.course_200_staff = self.create_staff_for_course(self.course_200)

        wiki_200 = self.create_urlpath(self.wiki, course_wiki_slug(self.course_200))
        wiki_200_page = self.create_urlpath(wiki_200, 'Child')
        wiki_200_page_page = self.create_urlpath(wiki_200_page, 'Grandchild')
        self.wiki_200_pages = [wiki_200, wiki_200_page, wiki_200_page_page]
Esempio n. 7
0
    def setUp(self):
        super(TestWikiAccessForNumericalCourseNumber, self).setUp()

        self.course_200 = CourseFactory.create(org='org', number='200', display_name='Course')
        self.course_200_staff = self.create_staff_for_course(self.course_200)

        wiki_200 = self.create_urlpath(self.wiki, course_wiki_slug(self.course_200))
        wiki_200_page = self.create_urlpath(wiki_200, 'Child')
        wiki_200_page_page = self.create_urlpath(wiki_200_page, 'Grandchild')
        self.wiki_200_pages = [wiki_200, wiki_200_page, wiki_200_page_page]
Esempio n. 8
0
    def setUp(self):
        super(TestWikiAccessForNumericalCourseNumber, self).setUp()

        self.course_200 = CourseFactory.create(org="org", number="200", display_name="Course")
        self.course_200_staff = self.create_staff_for_course(self.course_200)

        wiki_200 = self.create_urlpath(self.wiki, course_wiki_slug(self.course_200))
        wiki_200_page = self.create_urlpath(wiki_200, "Child")
        wiki_200_page_page = self.create_urlpath(wiki_200_page, "Grandchild")
        self.wiki_200_pages = [wiki_200, wiki_200_page, wiki_200_page_page]
Esempio n. 9
0
    def setUp(self):

        self.wiki = get_or_create_root()

        self.course_math101 = CourseFactory.create(org='org', number='math101', display_name='Course', metadata={'use_unique_wiki_id': 'false'})
        self.course_math101_staff = self.create_staff_for_course(self.course_math101)

        wiki_math101 = self.create_urlpath(self.wiki, course_wiki_slug(self.course_math101))
        wiki_math101_page = self.create_urlpath(wiki_math101, 'Child')
        wiki_math101_page_page = self.create_urlpath(wiki_math101_page, 'Grandchild')
        self.wiki_math101_pages = [wiki_math101, wiki_math101_page, wiki_math101_page_page]

        self.course_math101b = CourseFactory.create(org='org', number='math101b', display_name='Course', metadata={'use_unique_wiki_id': 'true'})
        self.course_math101b_staff = self.create_staff_for_course(self.course_math101b)

        wiki_math101b = self.create_urlpath(self.wiki, course_wiki_slug(self.course_math101b))
        wiki_math101b_page = self.create_urlpath(wiki_math101b, 'Child')
        wiki_math101b_page_page = self.create_urlpath(wiki_math101b_page, 'Grandchild')
        self.wiki_math101b_pages = [wiki_math101b, wiki_math101b_page, wiki_math101b_page_page]
Esempio n. 10
0
    def setUp(self):

        self.wiki = get_or_create_root()

        self.course_math101 = CourseFactory.create(org='org', number='math101', display_name='Course', metadata={'use_unique_wiki_id': 'false'})
        self.course_math101_staff = self.create_staff_for_course(self.course_math101)

        wiki_math101 = self.create_urlpath(self.wiki, course_wiki_slug(self.course_math101))
        wiki_math101_page = self.create_urlpath(wiki_math101, 'Child')
        wiki_math101_page_page = self.create_urlpath(wiki_math101_page, 'Grandchild')
        self.wiki_math101_pages = [wiki_math101, wiki_math101_page, wiki_math101_page_page]

        self.course_math101b = CourseFactory.create(org='org', number='math101b', display_name='Course', metadata={'use_unique_wiki_id': 'true'})
        self.course_math101b_staff = self.create_staff_for_course(self.course_math101b)

        wiki_math101b = self.create_urlpath(self.wiki, course_wiki_slug(self.course_math101b))
        wiki_math101b_page = self.create_urlpath(wiki_math101b, 'Child')
        wiki_math101b_page_page = self.create_urlpath(wiki_math101b_page, 'Grandchild')
        self.wiki_math101b_pages = [wiki_math101b, wiki_math101b_page, wiki_math101b_page_page]
Esempio n. 11
0
    def setUp(self):

        self.wiki = get_or_create_root()

        self.course_math101 = CourseFactory.create(org='org', number='math101', display_name='Course')
        self.course_math101_staff = [InstructorFactory(course=self.course_math101.location), StaffFactory(course=self.course_math101.location)]

        wiki_math101 = self.create_urlpath(self.wiki, course_wiki_slug(self.course_math101))
        wiki_math101_page = self.create_urlpath(wiki_math101, 'Child')
        wiki_math101_page_page = self.create_urlpath(wiki_math101_page, 'Grandchild')
        self.wiki_math101_pages = [wiki_math101, wiki_math101_page, wiki_math101_page_page]
Esempio n. 12
0
def get_urlpath(course_id):
    """Returns url path of root wiki page for course."""
    # Offical edX way to replace slashes by dots: course_key.replace('/', '.')
    course_key = CourseKey.from_string(course_id)
    course = get_course_by_id(course_key)
    course_slug = course_wiki_slug(course)
    try:
        urlpath = URLPath.get_by_path(course_slug)
    except URLPath.DoesNotExist:
        urlpath = None
    return urlpath
Esempio n. 13
0
    def setUp(self):
        super(TestWikiAccessForOldFormatCourseStaffGroups, self).setUp()

        self.course_math101c = CourseFactory.create(org='org', number='math101c', display_name='Course')
        Group.objects.get_or_create(name='instructor_math101c')
        self.course_math101c_staff = self.create_staff_for_course(self.course_math101c)

        wiki_math101c = self.create_urlpath(self.wiki, course_wiki_slug(self.course_math101c))
        wiki_math101c_page = self.create_urlpath(wiki_math101c, 'Child')
        wiki_math101c_page_page = self.create_urlpath(wiki_math101c_page, 'Grandchild')
        self.wiki_math101c_pages = [wiki_math101c, wiki_math101c_page, wiki_math101c_page_page]
Esempio n. 14
0
    def setUp(self):
        super(TestWikiAccessForOldFormatCourseStaffGroups, self).setUp()

        self.course_math101c = CourseFactory.create(org="org", number="math101c", display_name="Course")
        Group.objects.get_or_create(name="instructor_math101c")
        self.course_math101c_staff = self.create_staff_for_course(self.course_math101c)

        wiki_math101c = self.create_urlpath(self.wiki, course_wiki_slug(self.course_math101c))
        wiki_math101c_page = self.create_urlpath(wiki_math101c, "Child")
        wiki_math101c_page_page = self.create_urlpath(wiki_math101c_page, "Grandchild")
        self.wiki_math101c_pages = [wiki_math101c, wiki_math101c_page, wiki_math101c_page_page]
Esempio n. 15
0
    def setUp(self):
        super(TestWikiAccessForOldFormatCourseStaffGroups, self).setUp()

        self.course_math101c = CourseFactory.create(org='org', number='math101c', display_name='Course')
        Group.objects.get_or_create(name='instructor_math101c')
        self.course_math101c_staff = self.create_staff_for_course(self.course_math101c)

        wiki_math101c = self.create_urlpath(self.wiki, course_wiki_slug(self.course_math101c))
        wiki_math101c_page = self.create_urlpath(wiki_math101c, 'Child')
        wiki_math101c_page_page = self.create_urlpath(wiki_math101c_page, 'Grandchild')
        self.wiki_math101c_pages = [wiki_math101c, wiki_math101c_page, wiki_math101c_page_page]
Esempio n. 16
0
    def setUp(self):
        super(TestWikiAccess, self).setUp()

        self.course_310b = CourseFactory.create(org='org',
                                                number='310b',
                                                display_name='Course')
        self.course_310b_staff = [
            InstructorFactory(course=self.course_310b.location),
            StaffFactory(course=self.course_310b.location)
        ]
        self.course_310b_ = CourseFactory.create(org='org',
                                                 number='310b_',
                                                 display_name='Course')
        self.course_310b__staff = [
            InstructorFactory(course=self.course_310b_.location),
            StaffFactory(course=self.course_310b_.location)
        ]

        self.wiki_310b = self.create_urlpath(
            self.wiki, course_wiki_slug(self.course_310b))
        self.wiki_310b_ = self.create_urlpath(
            self.wiki, course_wiki_slug(self.course_310b_))
Esempio n. 17
0
    def setUp(self):

        self.wiki = get_or_create_root()

        self.course_math101 = CourseFactory.create(
            org="org", number="math101", display_name="Course", metadata={"use_unique_wiki_id": "false"}
        )
        self.course_math101_staff = self.create_staff_for_course(self.course_math101)

        wiki_math101 = self.create_urlpath(self.wiki, course_wiki_slug(self.course_math101))
        wiki_math101_page = self.create_urlpath(wiki_math101, "Child")
        wiki_math101_page_page = self.create_urlpath(wiki_math101_page, "Grandchild")
        self.wiki_math101_pages = [wiki_math101, wiki_math101_page, wiki_math101_page_page]

        self.course_math101b = CourseFactory.create(
            org="org", number="math101b", display_name="Course", metadata={"use_unique_wiki_id": "true"}
        )
        self.course_math101b_staff = self.create_staff_for_course(self.course_math101b)

        wiki_math101b = self.create_urlpath(self.wiki, course_wiki_slug(self.course_math101b))
        wiki_math101b_page = self.create_urlpath(wiki_math101b, "Child")
        wiki_math101b_page_page = self.create_urlpath(wiki_math101b_page, "Grandchild")
        self.wiki_math101b_pages = [wiki_math101b, wiki_math101b_page, wiki_math101b_page_page]
Esempio n. 18
0
def get_base_page(course):
    """Returns course base wiki page.
        Args:    course (Mongo object)
        Returns: URLPath
    """
    import wiki.models.urlpath

    root = wiki.models.urlpath.URLPath.get_by_path('/')
    slug = course_wiki_slug(course)
    try:
        base_page = wiki.models.urlpath.URLPath.objects.select_related("article").get(parent=root, slug=slug)  # retrieve base page
    except wiki.models.urlpath.URLPath.DoesNotExist:
        base_page = None
    return base_page
Esempio n. 19
0
    def test(self):

        self.course = CourseFactory.create()
        self.wiki = get_or_create_root()

        wiki_page = self.create_urlpath(self.wiki, course_wiki_slug(self.course))
        wiki_page2 = self.create_urlpath(wiki_page, 'Child')
        wiki_page3 = self.create_urlpath(wiki_page2, 'Grandchild')

        instructor = InstructorFactory.create(course_key=self.course.id)
        self.client.login(username=instructor.username, password="******")

        response = self.client.get(reverse('course-dashboard:wiki-activity',
                kwargs={'course_id': self.course.id.to_deprecated_string()}))
        self.assertEqual(200, response.status_code)
Esempio n. 20
0
def get_base_page(course):
    """Returns course base wiki page.
        Args:    course (Mongo object)
        Returns: URLPath
    """
    import wiki.models.urlpath

    root = wiki.models.urlpath.URLPath.get_by_path('/')
    slug = course_wiki_slug(course)
    try:
        base_page = wiki.models.urlpath.URLPath.objects.select_related(
            "article").get(parent=root, slug=slug)  # retrieve base page
    except wiki.models.urlpath.URLPath.DoesNotExist:
        base_page = None
    return base_page
Esempio n. 21
0
    def test_get_activity(self):
        from course_wiki.views import get_or_create_root
        from course_wiki.utils import course_wiki_slug

        course = CourseFactory.create()
        wiki = get_or_create_root()

        wiki_page = self.create_urlpath(wiki, course_wiki_slug(course))
        wiki_page2 = self.create_urlpath(wiki_page, 'Child')
        _wiki_page3 = self.create_urlpath(wiki_page2, 'Grandchild')

        instructor = InstructorFactory.create(course_key=course.id)
        self.client.login(username=instructor.username, password="******")

        # TODO we should probably test something more here
        response = self.client.get(reverse('course-dashboard:wiki-activity',
                kwargs={'course_id': course.id.to_deprecated_string()}))
        self.assertEqual(200, response.status_code)
Esempio n. 22
0
    def setUp(self):

        self.wiki = get_or_create_root()

        self.course_math101 = CourseFactory.create(org='org',
                                                   number='math101',
                                                   display_name='Course')
        self.course_math101_staff = [
            InstructorFactory(course=self.course_math101.location),
            StaffFactory(course=self.course_math101.location)
        ]

        wiki_math101 = self.create_urlpath(
            self.wiki, course_wiki_slug(self.course_math101))
        wiki_math101_page = self.create_urlpath(wiki_math101, 'Child')
        wiki_math101_page_page = self.create_urlpath(wiki_math101_page,
                                                     'Grandchild')
        self.wiki_math101_pages = [
            wiki_math101, wiki_math101_page, wiki_math101_page_page
        ]
Esempio n. 23
0
def course_wiki_redirect(request, course_id):  # pylint: disable=unused-argument
    """
    This redirects to whatever page on the wiki that the course designates
    as it's home page. A course's wiki must be an article on the root (for
    example, "/6.002x") to keep things simple.
    """
    course = get_course_by_id(SlashSeparatedCourseKey.from_deprecated_string(course_id))
    course_slug = course_wiki_slug(course)

    valid_slug = True
    if not course_slug:
        log.exception("This course is improperly configured. The slug cannot be empty.")
        valid_slug = False
    if re.match(r'^[-\w\.]+$', course_slug) is None:
        log.exception("This course is improperly configured. The slug can only contain letters, numbers, periods or hyphens.")
        valid_slug = False

    if not valid_slug:
        return redirect("wiki:get", path="")

    # The wiki needs a Site object created. We make sure it exists here
    try:
        Site.objects.get_current()
    except Site.DoesNotExist:
        new_site = Site()
        new_site.domain = settings.SITE_NAME
        new_site.name = "edX"
        new_site.save()
        site_id = str(new_site.id)
        if site_id != str(settings.SITE_ID):
            msg = "No site object was created and the SITE_ID doesn't match the newly created one. {} != {}".format(
                site_id, settings.SITE_ID
            )
            raise ImproperlyConfigured(msg)

    try:
        urlpath = URLPath.get_by_path(course_slug, select_related=True)

        results = list(Article.objects.filter(id=urlpath.article.id))
        if results:
            article = results[0]
        else:
            article = None

    except (NoRootURL, URLPath.DoesNotExist):
        # We will create it in the next block
        urlpath = None
        article = None

    if not article:
        # create it
        root = get_or_create_root()

        if urlpath:
            # Somehow we got a urlpath without an article. Just delete it and
            # recerate it.
            urlpath.delete()

        content = cgi.escape(
            # Translators: this string includes wiki markup.  Leave the ** and the _ alone.
            _("This is the wiki for **{organization}**'s _{course_name}_.").format(
                organization=course.display_org_with_default,
                course_name=course.display_name_with_default_escaped,
            )
        )
        urlpath = URLPath.create_article(
            root,
            course_slug,
            title=course_slug,
            content=content,
            user_message=_("Course page automatically created."),
            user=None,
            ip_address=None,
            article_kwargs={'owner': None,
                            'group': None,
                            'group_read': True,
                            'group_write': True,
                            'other_read': True,
                            'other_write': True,
                            })

    return redirect("wiki:get", path=urlpath.path)
Esempio n. 24
0
def course_wiki_redirect(request, course_id, wiki_path=""):  # pylint: disable=unused-argument
    """
    This redirects to whatever page on the wiki that the course designates
    as it's home page. A course's wiki must be an article on the root (for
    example, "/6.002x") to keep things simple.
    """
    course = get_course_by_id(CourseKey.from_string(course_id))
    course_slug = course_wiki_slug(course)

    valid_slug = True
    if not course_slug:
        log.exception(
            "This course is improperly configured. The slug cannot be empty.")
        valid_slug = False
    if re.match(r'^[-\w\.]+$', course_slug) is None:
        log.exception(
            "This course is improperly configured. The slug can only contain letters, numbers, periods or hyphens."
        )
        valid_slug = False

    if not valid_slug:
        return redirect("wiki:get", path="")

    try:
        urlpath = URLPath.get_by_path(wiki_path or course_slug,
                                      select_related=True)

        results = list(Article.objects.filter(id=urlpath.article.id))
        if results:
            article = results[0]
        else:
            article = None

    except (NoRootURL, URLPath.DoesNotExist):
        # We will create it in the next block
        urlpath = None
        article = None

    if not article:
        # create it
        root = get_or_create_root()

        if urlpath:
            # Somehow we got a urlpath without an article. Just delete it and
            # recerate it.
            urlpath.delete()

        content = cgi.escape(
            # Translators: this string includes wiki markup.  Leave the ** and the _ alone.
            _("This is the wiki for **{organization}**'s _{course_name}_."
              ).format(
                  organization=course.display_org_with_default,
                  course_name=course.display_name_with_default_escaped,
              ))
        urlpath = URLPath.create_article(
            root,
            course_slug,
            title=course.display_name_with_default,
            content=content,
            user_message=_("Course page automatically created."),
            user=None,
            ip_address=None,
            article_kwargs={
                'owner': None,
                'group': None,
                'group_read': True,
                'group_write': True,
                'other_read': True,
                'other_write': True,
            })

    return redirect("wiki:get", path=urlpath.path)
Esempio n. 25
0
def course_wiki_redirect(request, course_id, wiki_path=""):  # pylint: disable=unused-argument
    """
    This redirects to whatever page on the wiki that the course designates
    as it's home page. A course's wiki must be an article on the root (for
    example, "/6.002x") to keep things simple.
    """
    course = get_course_by_id(CourseKey.from_string(course_id))
    course_slug = course_wiki_slug(course)

    valid_slug = True
    if not course_slug:
        log.exception("This course is improperly configured. The slug cannot be empty.")
        valid_slug = False
    if re.match(r'^[-\w\.]+$', course_slug) is None:
        log.exception("This course is improperly configured. The slug can only contain letters, numbers, periods or hyphens.")
        valid_slug = False

    if not valid_slug:
        return redirect("wiki:get", path="")

    try:
        urlpath = URLPath.get_by_path(wiki_path or course_slug, select_related=True)

        results = list(Article.objects.filter(id=urlpath.article.id))
        if results:
            article = results[0]
        else:
            article = None

    except (NoRootURL, URLPath.DoesNotExist):
        # We will create it in the next block
        urlpath = None
        article = None

    if not article:
        # create it
        root = get_or_create_root()

        if urlpath:
            # Somehow we got a urlpath without an article. Just delete it and
            # recerate it.
            urlpath.delete()

        content = Text(
            # Translators: this string includes wiki markup.  Leave the ** and the _ alone.
            _(u"This is the wiki for **{organization}**'s _{course_name}_.")
        ).format(
            organization=course.display_org_with_default,
            course_name=course.display_name_with_default,
        )
        urlpath = URLPath.create_article(
            root,
            course_slug,
            title=course.display_name_with_default,
            content=content,
            user_message=_("Course page automatically created."),
            user=None,
            ip_address=None,
            article_kwargs={'owner': None,
                            'group': None,
                            'group_read': True,
                            'group_write': True,
                            'other_read': True,
                            'other_write': True,
                            })

    return redirect("wiki:get", path=urlpath.path)
Esempio n. 26
0
def course_wiki_redirect(request, course_id):  # pylint: disable=W0613
    """
    This redirects to whatever page on the wiki that the course designates
    as it's home page. A course's wiki must be an article on the root (for
    example, "/6.002x") to keep things simple.
    """
    course = get_course_by_id(
        SlashSeparatedCourseKey.from_deprecated_string(course_id))
    course_slug = course_wiki_slug(course)

    valid_slug = True
    if not course_slug:
        log.exception(
            "This course is improperly configured. The slug cannot be empty.")
        valid_slug = False
    if re.match(r'^[-\w\.]+$', course_slug) is None:
        log.exception(
            "This course is improperly configured. The slug can only contain letters, numbers, periods or hyphens."
        )
        valid_slug = False

    if not valid_slug:
        return redirect("wiki:get", path="")

    # The wiki needs a Site object created. We make sure it exists here
    try:
        Site.objects.get_current()
    except Site.DoesNotExist:
        new_site = Site()
        new_site.domain = settings.SITE_NAME
        new_site.name = "edX"
        new_site.save()
        site_id = str(new_site.id)  # pylint: disable=E1101
        if site_id != str(settings.SITE_ID):
            raise ImproperlyConfigured(
                "No site object was created and the SITE_ID doesn't match the newly created one. {} != {}"
                .format(site_id, settings.SITE_ID))

    try:
        urlpath = URLPath.get_by_path(course_slug, select_related=True)

        results = list(Article.objects.filter(id=urlpath.article.id))
        if results:
            article = results[0]
        else:
            article = None

    except (NoRootURL, URLPath.DoesNotExist):
        # We will create it in the next block
        urlpath = None
        article = None

    if not article:
        # create it
        root = get_or_create_root()

        if urlpath:
            # Somehow we got a urlpath without an article. Just delete it and
            # recerate it.
            urlpath.delete()

        content = cgi.escape(
            # Translators: this string includes wiki markup.  Leave the ** and the _ alone.
            _("This is the wiki for **{organization}**'s _{course_name}_."
              ).format(
                  organization=course.display_org_with_default,
                  course_name=course.display_name_with_default,
              ))
        urlpath = URLPath.create_article(
            root,
            course_slug,
            title=course_slug,
            content=content,
            user_message=_("Course page automatically created."),
            user=None,
            ip_address=None,
            article_kwargs={
                'owner': None,
                'group': None,
                'group_read': True,
                'group_write': True,
                'other_read': True,
                'other_write': True,
            })

    return redirect("wiki:get", path=urlpath.path)