예제 #1
0
파일: management.py 프로젝트: ogonbat/chano
 def parse_frontend_url(self):
     tag = self.root.find('urls')
     if tag is not None:
         path = tag.get('path')
         try:
             url_object = UrlPatterns.objects.get(path=path,application=self.app,is_frontend=True)
         except UrlPatterns.DoesNotExist:
             url_object = UrlPatterns()
         url_object.path = path
         url_object.regex = tag.get('regex')
         url_object.is_frontend = True
         url_object.application=self.app
         url_object.save()
예제 #2
0
파일: management.py 프로젝트: ogonbat/chano
 def parse_rest_section(self):
     url = self.root.find("rest")
     if url is not None:
         for rest_url in url.findall("url"):
             path = rest_url.get("path")
             try:
                 rest_object = UrlPatterns.objects.get(path=path,application=self.app,is_rest=True)
             except UrlPatterns.DoesNotExist:
                 rest_object = UrlPatterns()
             rest_object.path = path
             rest_object.regex = rest_url.get("regex")
             rest_object.application = self.app
             rest_object.is_rest = True
             rest_object.save()
예제 #3
0
파일: management.py 프로젝트: ogonbat/chano
    def parse_admin_section(self):
    #include the admin url
        admin_url = self.root.find("admin")
        if admin_url is not None:
            print "passa"
            for url_admin_obj in admin_url.findall("url"):
                path = url_admin_obj.get("path")
                print path
                try:
                    admin_url_object = UrlPatterns.objects.get(path=path,application=self.app,is_admin=True)
                except UrlPatterns.DoesNotExist:
                    admin_url_object = UrlPatterns()
                admin_url_object.path = path
                admin_url_object.regex = url_admin_obj.get("regex")
                admin_url_object.application = self.app
                admin_url_object.is_admin = True
                admin_url_object.save()
                #include admin menu
            admin_menu = admin_url.find('menus')
            if admin_menu is not None:
                for admin_menu_item in admin_menu.findall('menu'):

                    admin_menu_path = admin_menu_item.get('url')
                    admin_menu_prompt = admin_menu_item.get('prompt')
                    admin_menu_name = admin_menu_item.get('name')
                    admin_menu_parent = admin_menu_item.get('parent',None)
                    admin_menu_icon = admin_menu_item.get('icon',None)

                    try:
                        adm_menu = AdminMenu.objects.get(name=admin_menu_name)
                    except AdminMenu.DoesNotExist:
                        adm_menu = AdminMenu()
                    adm_menu.name = admin_menu_name
                    adm_menu.path = admin_menu_path
                    adm_menu.prompt = admin_menu_prompt
                    adm_menu.icon = admin_menu_icon
                    if admin_menu_parent is not None:
                        try:
                            adm_menu.parent = AdminMenu.objects.get(name=admin_menu_parent)
                        except AdminMenu.DoesNotExist:
                            print "an error occurred, the parent module %s doesn't exist"%admin_menu_parent
                    adm_menu.save()