当前位置: 首页>>代码示例>>Python>>正文


Python Manifest.list方法代码示例

本文整理汇总了Python中models.Manifest.list方法的典型用法代码示例。如果您正苦于以下问题:Python Manifest.list方法的具体用法?Python Manifest.list怎么用?Python Manifest.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Manifest的用法示例。


在下文中一共展示了Manifest.list方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: detail

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def detail(request, manifest_name):
    if request.method == 'POST':
        if not request.user.has_perm('reports.change_machine'):
            return HttpResponse(json.dumps('error'))
        if request.is_ajax():
            json_data = json.loads(request.raw_post_data)
            if json_data:
                manifest_detail = Manifest.read(manifest_name)
                for key in json_data.keys():
                    manifest_detail[key] = json_data[key]
                Manifest.write(manifest_name, manifest_detail,
                               request.user)
            return HttpResponse(json.dumps('success'))
    if request.method == 'GET':
        manifest = Manifest.read(manifest_name)
        valid_install_items = Manifest.getValidInstallItems(manifest_name)
        valid_catalogs = Catalog.list()
        valid_manifest_names = Manifest.list()
        manifest_user = manifest.get(MANIFEST_USERNAME_KEY, '')
        
        c = RequestContext(request, 
            {'manifest_name': manifest_name.replace(':', '/'),
            'manifest_user': manifest_user,
            'manifest_user_is_editable': MANIFEST_USERNAME_IS_EDITABLE,
            'manifest': manifest,
            'valid_install_items': valid_install_items,
            'valid_catalogs': valid_catalogs,
            'valid_manifest_names': valid_manifest_names,
            'user': request.user,
            'page': 'manifests'})
        c.update(csrf(request))
        return render_to_response('manifests/detail.html', c)
开发者ID:brianmickelson,项目名称:munkiwebadmin,代码行数:34,代码来源:views.py

示例2: index

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def index(request, manifest_name=None):
    if request.method == 'GET':
        manifest_names = Manifest.list()
        available_sections =   ['catalogs',
                                'included_manifests',
                                'managed_installs',
                                'managed_uninstalls',
                                'managed_updates',
                                'optional_installs']
        section = request.GET.get('section', 'manifest_name')
        findtext = request.GET.get('findtext', '')
        #sort = request.GET.get('sort', 'name')
        if findtext:
            filtered_names = []
            if section == 'manifest_name':
                for name in manifest_names:
                    basename = os.path.basename(name)
                    if fnmatch.fnmatch(basename, findtext):
                        filtered_names.append(name)
            elif section == 'user_name':
                for name in manifest_names:
                    manifest = Manifest.read(name)
                    if manifest:
                        username = manifest.get(MANIFEST_USERNAME_KEY, '')
                        if fnmatch.fnmatch(username, findtext):
                            filtered_names.append(name)
            else:
                for name in manifest_names:
                    manifest = Manifest.read(name)
                    if manifest:
                        for item in manifest.get(section, []):
                            if fnmatch.fnmatch(item, findtext):
                                filtered_names.append(name)
                                break
        
            manifest_names = filtered_names
        
        manifest_list = getManifestInfo(manifest_names)
        username = None
        manifest = None
        
        if manifest_name:
            manifest = Manifest.read(manifest_name)
            username = manifest.get(MANIFEST_USERNAME_KEY)
            manifest_name = manifest_name.replace(':', '/')
        c = RequestContext(request,     
            {'manifest_list': manifest_list,
             'section': section,
             'findtext': findtext,
             'available_sections': available_sections,
             'manifest_name': manifest_name,
             'manifest_user': username,
             'manifest': manifest,
             'user': request.user,
             'page': 'manifests'})
        
        return render_to_response('manifests/index.html', c)
开发者ID:brianmickelson,项目名称:munkiwebadmin,代码行数:59,代码来源:views.py

示例3: json_manifest_names

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def json_manifest_names(request):
    valid_manifest_names = Manifest.list()
    valid_manifest_names.sort()
    term = request.GET.get('term', '').lower()
    if term:
        suggestions = [ item for item in valid_manifest_names
                        if term in item.lower() ]
    else:
        suggestions = valid_manifest_names
    return HttpResponse(json.dumps(suggestions),
                        mimetype='application/json')
开发者ID:brianmickelson,项目名称:munkiwebadmin,代码行数:13,代码来源:views.py

示例4: index

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def index(request):
    if request.is_ajax():
        print "Got json request for manifests"
        manifest_list = Manifest.list()
        # send it back in JSON format
        return HttpResponse(json.dumps(manifest_list),
                            content_type='application/json')
    else:
        print "Got index request for manifests"
        c = {'page': 'manifests'}
        return render(request, 'manifests/manifests.html', context=c)
开发者ID:wollardj,项目名称:mwa2,代码行数:13,代码来源:views.py

示例5: index

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def index(request, manifest_name=None):
    if request.method == 'GET':
        manifest_names = Manifest.list()
        available_sections =   ['catalogs',
                                'included_manifests',
                                'managed_installs',
                                'managed_uninstalls',
                                'managed_updates',
                                'optional_installs']
        section = request.GET.get('section', 'manifest_name')
        findtext = request.GET.get('findtext', '')
        sort = request.GET.get('sort', 'name')

        manifest_list = getManifestInfo(manifest_names)
        username = None
        manifest = None
        
        git_enabled = None
        if GIT:
            git_enabled = GIT

        git_branching_enabled = None
        if GIT_BRANCHING:
            git_branching_enabled = GIT_BRANCHING
            # option to show the actual branch. It takes a toll on loading speed though
            # git_branch = Manifest.getGitBranch()

        manifest_list_json = list()
        for item in manifest_list:
            manifest_list_json.append(item['name'])
        manifest_list_json = json.dumps(manifest_list_json)

        if manifest_name:
            manifest = Manifest.read(manifest_name)
            username = manifest.get(MANIFEST_USERNAME_KEY)
            manifest_name = manifest_name.replace(':', '/')
        c = RequestContext(request,     
            {'manifest_list': manifest_list,
             'manifest_list_json': manifest_list_json,
             'section': section,
             'findtext': findtext,
             'available_sections': available_sections,
             'manifest_name': manifest_name,
             'manifest_user': username,
             'manifest': manifest,
             'git_enabled': git_enabled,
             'git_branching_enabled': git_branching_enabled,
             'user': request.user,
             'page': 'manifests'})
        
        return render_to_response('manifests/index.html', c)
开发者ID:grahampugh,项目名称:munki-do,代码行数:53,代码来源:views.py

示例6: detail

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def detail(request, manifest_name):
    if request.method == 'POST':
        if not request.user.has_perm('manifests.change_manifests'):
            return HttpResponse(json.dumps('error'))
        if request.is_ajax():
            json_data = json.loads(request.body)
            if json_data:
                manifest_detail = Manifest.read(manifest_name)
                for key in json_data.keys():
                    manifest_detail[key] = json_data[key]
                Manifest.write(manifest_name, manifest_detail,
                               request.user)
            return HttpResponse(json.dumps('success'))
    if request.method == 'GET':
        if not request.user.has_perm('manifests.can_view_manifests'):
            return HttpResponse(json.dumps('error'))
        manifest = Manifest.read(manifest_name)
        #valid_install_items = Manifest.getValidInstallItems(manifest_name)
        install_items = Manifest.getInstallItemNames(manifest_name)
        valid_install_items = (install_items['suggested'] + 
                               install_items['updates'] +
                                install_items['with_version'])
        suggested_install_items = install_items['suggested']
        valid_catalogs = Catalog.list()
        valid_manifest_names = Manifest.list()
        autocomplete_data = json.dumps({
            'items': install_items['suggested'],
            'catalogs': valid_catalogs,
            'manifests': valid_manifest_names
        })
        manifest_user = manifest.get(MANIFEST_USERNAME_KEY, '')
        
        c = RequestContext(request, 
            {'manifest_name': manifest_name.replace(':', '/'),
            'manifest_user': manifest_user,
            'manifest_user_is_editable': MANIFEST_USERNAME_IS_EDITABLE,
            'manifest': manifest,
            'valid_install_items': valid_install_items,
            'install_items': install_items,
            'valid_catalogs': valid_catalogs,
            'valid_manifest_names': valid_manifest_names,
            'autocomplete_data': autocomplete_data,
            'user': request.user,
            'page': 'manifests'})
        c.update(csrf(request))
        return render_to_response('manifests/detail.html', c)
开发者ID:oliof,项目名称:munkiwebadmin,代码行数:48,代码来源:views.py

示例7: detail

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def detail(request, manifest_name):
    if request.method == "POST":
        if not request.user.has_perm("reports.change_machine"):
            return HttpResponse(json.dumps("error"))
        if request.is_ajax():
            json_data = json.loads(request.body)
            if json_data:
                manifest_detail = Manifest.read(manifest_name)
                for key in json_data.keys():
                    manifest_detail[key] = json_data[key]
                Manifest.write(manifest_name, manifest_detail, request.user)
            return HttpResponse(json.dumps("success"))
    if request.method == "GET":
        manifest = Manifest.read(manifest_name)
        # valid_install_items = Manifest.getValidInstallItems(manifest_name)
        install_items = Manifest.getInstallItemNames(manifest_name)
        valid_install_items = install_items["suggested"] + install_items["updates"] + install_items["with_version"]
        suggested_install_items = install_items["suggested"]
        valid_catalogs = Catalog.list()
        valid_manifest_names = Manifest.list()
        autocomplete_data = json.dumps(
            {"items": install_items["suggested"], "catalogs": valid_catalogs, "manifests": valid_manifest_names}
        )
        manifest_user = manifest.get(MANIFEST_USERNAME_KEY, "")

        c = RequestContext(
            request,
            {
                "manifest_name": manifest_name.replace(":", "/"),
                "manifest_user": manifest_user,
                "manifest_user_is_editable": MANIFEST_USERNAME_IS_EDITABLE,
                "manifest": manifest,
                "valid_install_items": valid_install_items,
                "install_items": install_items,
                "valid_catalogs": valid_catalogs,
                "valid_manifest_names": valid_manifest_names,
                "autocomplete_data": autocomplete_data,
                "user": request.user,
                "page": "manifests",
            },
        )
        c.update(csrf(request))
        return render_to_response("manifests/detail.html", c)
开发者ID:eahrold,项目名称:munkiwebadmin,代码行数:45,代码来源:views.py

示例8: index

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def index(request, manifest_name=None):
    if request.method == 'GET':
        manifest_names = Manifest.list()
        available_sections =   ['catalogs',
                                'included_manifests',
                                'managed_installs',
                                'managed_uninstalls',
                                'managed_updates',
                                'optional_installs']
        section = request.GET.get('section', 'manifest_name')
        findtext = request.GET.get('findtext', '')
        sort = request.GET.get('sort', 'name')

        manifest_list = getManifestInfo(manifest_names)
        username = None
        manifest = None
        
        manifest_list_josn = list()
        for item in manifest_list:
            manifest_list_josn.append(item['name'])
        manifest_list_josn = json.dumps(manifest_list_josn)

        if manifest_name:
            manifest = Manifest.read(manifest_name)
            username = manifest.get(MANIFEST_USERNAME_KEY)
            manifest_name = manifest_name.replace(':', '/')
        c = RequestContext(request,     
            {'manifest_list': manifest_list,
             'manifest_list_josn': manifest_list_josn,
             'section': section,
             'findtext': findtext,
             'available_sections': available_sections,
             'manifest_name': manifest_name,
             'manifest_user': username,
             'manifest': manifest,
             'user': request.user,
             'page': 'manifests'})
        
        return render_to_response('manifests/index.html', c)
开发者ID:oliof,项目名称:munkiwebadmin,代码行数:41,代码来源:views.py

示例9: clean_manifest_name

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
 def clean_manifest_name(self):
     manifest_names = Manifest.list()
     if self.cleaned_data['manifest_name'] in manifest_names:
         raise forms.ValidationError('Manifest name already exists!')
     return self.cleaned_data['manifest_name']
开发者ID:brianmickelson,项目名称:munkiwebadmin,代码行数:7,代码来源:views.py

示例10: old_json_manifest_names

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def old_json_manifest_names(request):
    valid_manifest_names = Manifest.list()
    valid_manifest_names.sort()
    return HttpResponse(json.dumps(valid_manifest_names),
                        mimetype='application/json')
开发者ID:brianmickelson,项目名称:munkiwebadmin,代码行数:7,代码来源:views.py

示例11: index

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def index(request, manifest_name=None):
    if request.method == "GET":
        manifest_names = Manifest.list()
        available_sections = [
            "catalogs",
            "included_manifests",
            "managed_installs",
            "managed_uninstalls",
            "managed_updates",
            "optional_installs",
        ]
        section = request.GET.get("section", "manifest_name")
        findtext = request.GET.get("findtext", "")
        # sort = request.GET.get('sort', 'name')
        if findtext:
            filtered_names = []
            if section == "manifest_name":
                for name in manifest_names:
                    basename = os.path.basename(name)
                    if fnmatch.fnmatch(basename, findtext):
                        filtered_names.append(name)
            elif section == "user_name":
                for name in manifest_names:
                    manifest = Manifest.read(name)
                    if manifest:
                        username = manifest.get(MANIFEST_USERNAME_KEY, "")
                        if fnmatch.fnmatch(username, findtext):
                            filtered_names.append(name)
            else:
                for name in manifest_names:
                    manifest = Manifest.read(name)
                    if manifest:
                        for item in manifest.get(section, []):
                            if fnmatch.fnmatch(item, findtext):
                                filtered_names.append(name)
                                break

            manifest_names = filtered_names

        manifest_list = getManifestInfo(manifest_names)
        username = None
        manifest = None

        if manifest_name:
            manifest = Manifest.read(manifest_name)
            username = manifest.get(MANIFEST_USERNAME_KEY)
            manifest_name = manifest_name.replace(":", "/")
        c = RequestContext(
            request,
            {
                "manifest_list": manifest_list,
                "section": section,
                "findtext": findtext,
                "available_sections": available_sections,
                "manifest_name": manifest_name,
                "manifest_user": username,
                "manifest": manifest,
                "user": request.user,
                "page": "manifests",
            },
        )

        return render_to_response("manifests/index.html", c)
开发者ID:eahrold,项目名称:munkiwebadmin,代码行数:65,代码来源:views.py

示例12: detail

# 需要导入模块: from models import Manifest [as 别名]
# 或者: from models.Manifest import list [as 别名]
def detail(request, manifest_name):
    if request.method == 'POST':
        if not request.user.has_perm('manifests.change_manifests'):
            return HttpResponse(json.dumps('error'))
        if request.is_ajax():
            json_data = json.loads(request.body)
            if json_data:
                manifest_detail = Manifest.read(manifest_name)
                for key in json_data.keys():
                    manifest_detail[key] = json_data[key]
                Manifest.write(manifest_name, manifest_detail,
                               request.user)
            logger.info("ManifestWrite instigated.")
            return HttpResponse(json.dumps('success'))
    
    if request.method == 'GET':
        if not request.user.has_perm('manifests.can_view_manifests'):
            return HttpResponse(json.dumps('error'))
        manifest = Manifest.read(manifest_name)
        #valid_install_items = Manifest.getValidInstallItems(manifest_name)
        install_items = Manifest.getInstallItemNames(manifest_name)
        valid_install_items =  (install_items['suggested'] + 
                                install_items['updates'] +
                                install_items['with_version'])
        suggested_install_items = install_items['suggested']
        valid_catalogs = Catalog.list()
        valid_manifest_names = Manifest.list()
        autocomplete_data = json.dumps({
            'items': install_items['suggested'],
            'catalogs': valid_catalogs,
            'manifests': valid_manifest_names
        })
        manifest_user = manifest.get(MANIFEST_USERNAME_KEY, '')
        manifest_restriction = manifest.get(MANIFEST_RESTRICTION_KEY, '')
        user_groups = Group.objects.values_list('name', flat=True)
        
        if manifest_restriction:
            manifest_restriction_is_editable = None
            if request.user.is_superuser:
                manifest_restriction_is_editable = 'yes'
            elif request.user.is_staff and 'staff' in manifest_restriction:
                manifest_restriction_is_editable = 'yes'
            else:
                for item in manifest_restriction:
                    if Manifest.can_edit_restricted_manifest(request.user, item):
                        manifest_restriction_is_editable = 'yes'
        else:
            manifest_restriction_is_editable = 'unrestricted'
 
        git_branching_enabled = None
        if GIT_BRANCHING:
            git_branching_enabled = GIT_BRANCHING

        c = RequestContext(request, 
            {'manifest_name': manifest_name.replace(':', '/'),
            'manifest_user': manifest_user,
            'manifest_user_is_editable': MANIFEST_USERNAME_IS_EDITABLE,
            'manifest': manifest,
            'valid_install_items': valid_install_items,
            'install_items': install_items,
            'valid_catalogs': valid_catalogs,
            'valid_manifest_names': valid_manifest_names,
            'autocomplete_data': autocomplete_data,
            'git_branching_enabled': git_branching_enabled,
            'restriction_key': MANIFEST_RESTRICTION_KEY,
            'manifest_restriction': manifest_restriction,
            'manifest_restriction_is_editable': manifest_restriction_is_editable,
            'user_groups': user_groups,
            'user': request.user,
            'page': 'manifests'})
        c.update(csrf(request))
        return render_to_response('manifests/detail.html', c)
开发者ID:grahampugh,项目名称:munki-do,代码行数:74,代码来源:views.py


注:本文中的models.Manifest.list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。