def create_nav_bar(self): from navbar.models import NavBarEntry nav = [ { "name": "News", "parent": None, "title": "News stories by topic", "url": "/news/", "user_type": "E", "path_type": "A", "order": 0, }, { "name": "Opinion", "parent": None, "title": "What we think about things", "url": "/opinion/", "user_type": "E", "path_type": "A", "order": 10, }, { "name": "Galleries", "parent": None, "title": "Photo essays on current events", "url": "/photos/galleries/", "user_type": "E", "path_type": "A", "order": 20, }, { "name": "Video", "parent": None, "title": "Video briefs", "url": "/video/", "user_type": "E", "path_type": "A", "order": 30, }, { "name": "Topics", "parent": None, "title": "Collections of stories on popular topics", "url": "/topics/", "user_type": "E", "path_type": "A", "order": 40, }, ] for item in nav: print "Creating Nav Bar Entry: %s" % (item["name"]) nav_entry = NavBarEntry(**item) nav_entry.save()
def create_nav_bar(self): from navbar.models import NavBarEntry nav = [{ "name": "News", "parent": None, "title": "News stories by topic", "url": "/news/", "user_type": "E", "path_type": "A", "order": 0 }, { "name": "Opinion", "parent": None, "title": "What we think about things", "url": "/opinion/", "user_type": "E", "path_type": "A", "order": 10 }, { "name": "Galleries", "parent": None, "title": "Photo essays on current events", "url": "/photos/galleries/", "user_type": "E", "path_type": "A", "order": 20 }, { "name": "Video", "parent": None, "title": "Video briefs", "url": "/video/", "user_type": "E", "path_type": "A", "order": 30 }, { "name": "Topics", "parent": None, "title": "Collections of stories on popular topics", "url": "/topics/", "user_type": "E", "path_type": "A", "order": 40 }] for item in nav: print "Creating Nav Bar Entry: %s" % (item['name']) nav_entry = NavBarEntry(**item) nav_entry.save()
def make_category(self, string, parent=None, order=1): """ Make and save a category object from a string """ slug = slugify(SLUG_TRANSLITERATOR(string.strip()))[:49] if parent: parent_url = parent.url.rstrip("/") else: parent_url = "" cat = NavBarEntry(name=string.strip(), slug=slug, url="%s/%s/" % (parent_url, slug), order=order) cat._tree_manager.insert_node(cat, parent, 'last-child', True) cat.save() if parent: parent.rght = cat.rght + 1 parent.save() return cat
def make_category(self, string, parent=None, order=1): """ Make and save a category object from a string """ slug = slugify(SLUG_TRANSLITERATOR(string.strip()))[:49] if parent: parent_url = parent.url.rstrip("/") else: parent_url = "" cat = NavBarEntry( name=string.strip(), slug=slug, url="%s/%s/" % (parent_url, slug), order=order ) cat._tree_manager.insert_node(cat, parent, 'last-child', True) cat.save() if parent: parent.rght = cat.rght + 1 parent.save() return cat