Exemplo n.º 1
0
 def get_uid(self, name, throw, default=None):
     param = get_uuid(self.store.get(name))
     if not param and throw:
         logger.warning('item not entered for %s : uid %s' %
                        (self.target, name))
         self.error(_('invalid item selected'), True, name)
     elif param:
         return param
     return default
Exemplo n.º 2
0
def get_type_sub_group(request):
    ext = get_uuid(request.GET.get('pk'))
    if not ext:
        return send_error(request, _('invalid item'))
    fields = ['ext', 'pk', 'name', 'remain_items', 'used_remain_items',
              'code__sell_price', 'code__used_sell_price', 'code__code']
    sort = get_full_sort(request.GET, fields)
    groups = EquipmentGroup.objects.filter(Q(remain_items__gt=0) | Q(used_remain_items__gt=0),
                                           equipment_type__ext=ext).values(*fields).order_by(sort)
    return HttpResponse(get_paginate(groups, request.GET.get('current'), request.GET.get('rowCount')))
Exemplo n.º 3
0
def remove_transport(request):
    t = get_uuid(request.GET.get('t'))
    if not t:
        return send_error(request, _('invalid item'))
    if not Transportation.objects.filter(pk=t, is_deleted=False).exists():
        return send_error(request, _('invalid item'))
    i = Transportation.objects.get(external=t)
    i.is_deleted = True
    i.save()
    return HttpResponse('200')
Exemplo n.º 4
0
 def get_single_ext(self, raise_error=False):
     store = self.store
     pk = get_uuid(store.get(self.pk_name))
     if not pk:
         self.error(_('invalid item'), raise_error)
     x = UserFloatTemplate.objects.filter(ext=pk).first()
     if x:
         if self.requester.has_perm('CRM.view_all_templates'):
             return x
         elif self.validate_selected(x):
             return x
     self.error(_('no such item'), raise_error)
Exemplo n.º 5
0
def view_pop_sites(request):
    if not check_ajax(request):
        return render(request, 'pop_site/PopSiteManagement.html', {
            'request': request,
            'has_nav': True
        })
    pops = PopSite.objects.filter(is_deleted=False)
    name = get_string(request.GET.get('searchPhrase'))
    pk = get_uuid(request.GET.get('pk'))
    if name:
        pops = pops.filter(name__icontains=name)
    if pk:
        pops = pops.filter(pk=pk)
    vls = pops.values('pk', 'name', 'description')
    res = get_paginate(vls, request.GET.get('current'),
                       request.GET.get('rowCount'))
    return HttpResponse(res)
Exemplo n.º 6
0
 def assign_ibs_services(self):
     services = self.req.POST.getlist('gr')
     c = self.get_single_ext(True)
     service_list = []
     for x in services:
         r = get_uuid(x)
         if r:
             service_list.append(r)
     if len(service_list) > 0:
         res = IBSService.objects.filter(ext__in=service_list)
         ServiceAlias.objects.filter(service=c.pk).delete()
         for r in res:
             al = ServiceAlias()
             al.service = c
             al.group = r
             al.save()
     return len(service_list)
Exemplo n.º 7
0
def get_custom_option_ext(ext):
    if not get_uuid(ext):
        return None
    if CustomOption.objects.filter(ext=ext).exists():
        return CustomOption.objects.get(ext=ext)
    return None
Exemplo n.º 8
0
def get_ibs_group(ext):
    if not get_uuid(ext):
        return None
    if IBSService.objects.filter(ext=ext, is_deleted=False).exists():
        return IBSService.objects.get(ext=ext)
    return None
Exemplo n.º 9
0
def get_float_services_ext(ext):
    if not get_uuid(ext):
        return None
    if not BasicService.objects.filter(ext=ext, is_deleted=False).exists():
        return None
    return BasicService.objects.get(ext=ext)
Exemplo n.º 10
0
def get_ibs_ip_pool(ext):
    if not get_uuid(ext):
        return None
    if IBSIpPool.objects.filter(ext=ext, is_deleted=False).exists():
        return IBSIpPool.objects.get(ext=ext)
    return None
Exemplo n.º 11
0
def get_charge_package_ext(pk):
    if not get_uuid(pk):
        return None
    if PricePackage.objects.filter(ext=pk, is_deleted=False).exists():
        return PricePackage.objects.get(ext=pk)
    return None