class Meta: queryset = Jails.objects.all() resource_name = 'jails' paginator_class = DojoPaginator authentication = DjangoAuthentication() include_resource_uri = False allowed_methods = ['get']
class Meta: queryset = bsdGroups.objects.order_by('bsdgrp_builtin', 'bsdgrp_gid') resource_name = 'bsdgroups' paginator_class = DojoPaginator authentication = DjangoAuthentication() include_resource_uri = False allowed_methods = ['get']
class Meta: queryset = NullMountPoint.objects.all() resource_name = 'nullmountpoint' paginator_class = DojoPaginator authentication = DjangoAuthentication() include_resource_uri = False allowed_methods = ['get']
class Meta: queryset = SMARTTest.objects.all() resource_name = 'smarttest' paginator_class = DojoPaginator authentication = DjangoAuthentication() include_resource_uri = False allowed_methods = ['get']
class Meta: queryset = iSCSITargetExtent.objects.all() resource_name = 'iscsitargetextent' paginator_class = DojoPaginator authentication = DjangoAuthentication() include_resource_uri = False allowed_methods = ['get']
class Meta: queryset = LAGGInterfaceMembers.objects.all() resource_name = 'lagginterfacemembers' paginator_class = DojoPaginator authentication = DjangoAuthentication() include_resource_uri = False allowed_methods = ['get']
class Meta: queryset = Volume.objects.all() resource_name = 'volumestatus' paginator_class = DojoPaginator authentication = DjangoAuthentication() include_resource_uri = False allowed_methods = ['get'] filtering = { 'id': ('exact', ), }
class Meta: queryset = Disk.objects.filter(disk_enabled=True, disk_multipath_name='').exclude( Q(disk_name__startswith='multipath') | Q(disk_name='')) resource_name = 'disk' paginator_class = DojoPaginator authentication = DjangoAuthentication() include_resource_uri = False allowed_methods = ['get']
class Meta: resource_name = 'availableplugins' include_resource_uri = False authentication = DjangoAuthentication() object_class = Plugin paginator_class = DojoPaginator
class Meta: resource_name = 'snapshot' include_resource_uri = False authentication = DjangoAuthentication() object_class = zfs.Snapshot paginator_class = DojoPaginator
def __init__(self, c=None, model=None, admin=None): self._model = model #FIXME: duplicated code if self.module_name is None: if self._model: self.module_name = self._model._meta.module_name else: raise ValueError("module_name cannot be None") if self.app_label is None: if self._model: self.app_label = self._model._meta.app_label else: raise ValueError("app_label cannot be None") if self.verbose_name is None: if self._model: self.verbose_name = self._model._meta.verbose_name else: raise ValueError("verbose_name cannot be None") if admin is not None: self._admin = admin if c is not None: obj = c() for i in dir(obj): if not i.startswith("__"): if not hasattr(self, i): raise Exception("The attribute '%s' is a not valid " "in FreeAdmin" % i) self.__setattr__(i, getattr(obj, i)) """ If no resource has been set lets automatically create a REST tastypie model resource The name defaults to the django model name (lowercase) Set resource to False to do not create one """ if self.resource is None and self._model: myMeta = type( 'Meta', (object, ), dict( queryset=self._model.objects.all(), resource_name=self.module_name, allowed_methods=['get'], include_resource_uri=False, paginator_class=DojoPaginator, authentication=DjangoAuthentication(), )) myres = type(self._model._meta.object_name + 'Resource', (DojoModelResource, ), dict(Meta=myMeta)) res = myres() self.resource = myres elif self.resource is False: res = None elif self.resource: res = self.resource() if res: self._admin.v1_api.register(res)
def get_urls(self): """ If no resource has been set lets automatically create a REST tastypie model resource The name defaults to the django model name (lowercase) Set resource to False to do not create one """ from freenasUI.freeadmin.api.utils import ( DojoModelResource, DjangoAuthentication, DojoPaginator ) if self.resource is None and self._model: myMeta = type('Meta', (object, ), dict( queryset=self._model.objects.all(), resource_name=self.module_name, allowed_methods=['get'], include_resource_uri=False, paginator_class=DojoPaginator, authentication=DjangoAuthentication(), )) myres = type( self._model._meta.object_name + 'Resource', (DojoModelResource, ), dict(Meta=myMeta) ) res = myres() self.resource = myres elif self.resource is False: res = None elif self.resource: res = self.resource() if res: self._admin.v1_api.register(res) def wrap(view): def wrapper(*args, **kwargs): return self._admin.admin_view(view)(*args, **kwargs) return update_wrapper(wrapper, view) info = self.app_label, self.module_name if self._model: urlpatterns = patterns( '', url(r'^add/(?P<mf>.+?)?$', wrap(self.add), name='freeadmin_%s_%s_add' % info), url(r'^edit/(?P<oid>\d+)/(?P<mf>.+?)?$', wrap(self.edit), name='freeadmin_%s_%s_edit' % info), url(r'^delete/(?P<oid>\d+)/$', wrap(self.delete), name='freeadmin_%s_%s_delete' % info), url(r'^empty-formset/$', wrap(self.empty_formset), name='freeadmin_%s_%s_empty_formset' % info), ) else: urlpatterns = patterns('') urlpatterns += patterns( '', url(r'^datagrid/$', wrap(self.datagrid), name='freeadmin_%s_%s_datagrid' % info), url(r'^structure/$', wrap(self.structure), name='freeadmin_%s_%s_structure' % info), url(r'^actions/$', wrap(self.actions), name='freeadmin_%s_%s_actions' % info), ) return urlpatterns