def create_alphabetic_urls(url_slug='ru'): ''' generate alphabetic table of content for selected language :param url_slug: :return: ''' urlpath = URLPath.objects.get(slug=url_slug) user = User.objects.get(username='******') article = Article.objects.get(urlpath=urlpath) for char in ALPHABET: try: URLPath.objects.get(slug=char) except ObjectDoesNotExist: URLPath.create_article(urlpath, char, title=char.upper(), content='[article_list depth:2]', user_message='', user=user, ip_address=None, article_kwargs={ 'owner': user, 'group': article.group, 'group_read': article.group_read, 'group_write': article.group_write, 'other_read': article.other_read, 'other_write': article.other_write, })
def create_article(self, parent, slug, title): from wiki.models.urlpath import URLPath return URLPath.create_article(parent, slug, title=title, article_kwargs={ 'group_write': True, 'other_write': True, })
def setUp(self): super(TestWikiUtils, self).setUp() from course_wiki.views import get_or_create_root from wiki.models.urlpath import URLPath self.wiki_root = get_or_create_root() self.course = CourseFactory.create(org='ORG', display_name='COURSE', number='RUN') self.wiki_course_root = URLPath.create_article(self.wiki_root, 'RUN', title=u"Page 0") self.page1 = URLPath.create_article(self.wiki_course_root, 'page1', title=u"Page 1") self.page2 = URLPath.create_article(self.wiki_course_root, 'page2', title=u"page 2") self.page11 = URLPath.create_article(self.page1, 'page11', title=u"page 1.1") self.page111 = URLPath.create_article(self.page11, 'page111', title=u"page 1.1.1") self.page112 = URLPath.create_article(self.page11, 'page112', title=u"page 1.1.2")