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


Python CuserMiddleware.get_user方法代码示例

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


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

示例1: unread_dialogs

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
def unread_dialogs():
	user = CuserMiddleware.get_user()
	if user.is_authenticated():
		d_count = get_unread_messages_count(user.id)
		if d_count > 0:
			return "+{}".format(d_count)
	return ""
开发者ID:enotikc,项目名称:np_station,代码行数:9,代码来源:chat_tags.py

示例2: bodega_actual

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
 def bodega_actual():
     user = CuserMiddleware.get_user()
     cuenta = Cuenta.objects.filter(pk=user.pk).first()
     if cuenta:
         return cuenta.bodega
     # end if
     return None
开发者ID:exildev,项目名称:piscix_demo,代码行数:9,代码来源:models.py

示例3: pre_save

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
 def pre_save(self, model_instance, add):
     if add or not self.add_only:
         user = CuserMiddleware.get_user()
         if user:
             setattr(model_instance, self.attname, user.pk)
             return user.pk
     return super(CurrentUserField, self).pre_save(model_instance, add)
开发者ID:VoNov,项目名称:django-cuser,代码行数:9,代码来源:fields.py

示例4: __init__

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
    def __init__(self, *args, **kwargs):
        super(NoSerialForm, self).__init__(*args, **kwargs)
        user = CuserMiddleware.get_user()
        cuenta = inv.Cuenta.objects.filter(pk=user.pk).first()
        if cuenta and self.fields.has_key('noserial'):
            self.fields['noserial'].queryset = inv.ActivoNoSerial.objects.filter(bodega=cuenta.bodega)

        # end if

        def clean(self):
            data = self.cleaned_data
            noserial = geo.GeoNoSerial.objects.filter(geoactivo=data['geoactivo'], noserial=data['noserial']).first()
            if noserial:
                raise forms.ValidationError("Ya tiene asignado/a una %s" % (data['noserial'].nombre))
            else:
                return data
            # end if

        # end def

        def clean_cantidad(self):
            if self.cleaned_data['cantidad']:
                cantidad = self.cleaned_data['cantidad']
                noserial = self.cleaned_data['noserial']
                if noserial:
                    if noserial.cantidad - cantidad < 0:
                        raise forms.ValidationError("La cantidad maxima disponible es %d" % (cantidad))
                    # end if
                    return cantidad
                # end if
                return forms.ValidationError("Seleccione un activo no serial")
            # end if
            return forms.ValidationError("Este campo es requerido")
开发者ID:mariobp,项目名称:geoactivos,代码行数:35,代码来源:forms.py

示例5: get_fields

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
	def get_fields(self, request, obj):
		fields = super(BillAdmin, self).get_fields(request, obj)
		user = CuserMiddleware.get_user()
		service = Service.objects.filter(userservice__user = user).first()
		if service:
			fields.remove('service')
		return fields
开发者ID:scriptquo,项目名称:pventa,代码行数:9,代码来源:admin.py

示例6: update

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
 def update(self, instance, validated_data):
     if not instance:
         return self.create(validated_data)
     #end if
     user = CuserMiddleware.get_user()
     service = venta.Service.objects.filter(userservice__user = user).first()
     
     order = instance
     if 'bill' in validated_data:
         order.bill = validated_data['bill']
     #end if
     if 'client' in validated_data:
         order.client  = validated_data['client']
     #end if
     if 'canceled' in validated_data:
         order.canceled  = validated_data['canceled']
     #end if
     order.service = service
     order.save()
     if 'products' in validated_data:
         order.products.all().delete()
         for item in validated_data['products']:
             itemorder = venta.ItemOrder.objects.create(product=item['product'], count=item['count'])
             order.products.add(itemorder)
         #end for
     #end if
     return order
开发者ID:scriptquo,项目名称:pventa,代码行数:29,代码来源:rest.py

示例7: save_model

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
	def save_model(self, request, obj, form, change):
		user = CuserMiddleware.get_user()
		service = Service.objects.filter(userservice__user = user).first()
		if service:
			obj.service = service
		#end if
		super(ClientAdmin, self).save_model(request, obj, form, change)
开发者ID:scriptquo,项目名称:pventa,代码行数:9,代码来源:admin.py

示例8: clean

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
 def clean(self):
     if self.instance.pk == None:
         user = CuserMiddleware.get_user()
         cuenta = inventario.Cuenta.objects.filter(pk=user.pk).first()
         if cuenta:
             return super(ActivoInsumoForm, self).clean()
         else:
             raise forms.ValidationError("Necesita tener una cuenta de bodega para registrar el activo no serial")
开发者ID:exildev,项目名称:piscix_demo,代码行数:10,代码来源:forms.py

示例9: __init__

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
 def __init__(self, *args, **kwargs):
     super(SalidaInsumoForm, self).__init__(*args, **kwargs)
     user = CuserMiddleware.get_user()
     cuenta = inventario.Cuenta.objects.filter(pk=user.pk).first()
     if cuenta:
         self.fields['activos'].queryset = ActivoInsumo.objects.filter(
             Q(bodega=cuenta.bodega, vendido=False) | Q(salidainsumo=self.instance))
         self.fields['destino'].queryset = Bodega.objects.all().exclude(id=cuenta.bodega.id)
开发者ID:exildev,项目名称:piscix_demo,代码行数:10,代码来源:forms.py

示例10: save

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
 def save(self, *args, **kwargs):
     user = CuserMiddleware.get_user()
     cuenta = Cuenta.objects.filter(pk=user.pk).first()
     if cuenta:
         self.creado_por = cuenta
         self.salida = cuenta.bodega
         super(SalidaInsumo, self).save(*args, **kwargs)
         self.activos.update(bodega=None)
开发者ID:exildev,项目名称:piscix_demo,代码行数:10,代码来源:models.py

示例11: clean

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
 def clean(self):
     if self.instance.pk == None:
         user = CuserMiddleware.get_user()
         cuenta = inv.Cuenta.objects.filter(pk=user.pk).first()
         if cuenta:
             self.instance.creado_por = cuenta
             return super(GeoActivoForm, self).clean()
         else:
             raise forms.ValidationError("Necesita tener una cuenta para crear el Apta de Salida")
开发者ID:mariobp,项目名称:geoactivos,代码行数:11,代码来源:forms.py

示例12: create

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
 def create(self, validated_data):
     user = CuserMiddleware.get_user()
     service = venta.Service.objects.filter(userservice__user = user).first()
     row = {
         'name': validated_data['name'],
         'service': service,
         'image': validated_data['image']
     }
     return venta.Category.objects.create(**row)
开发者ID:scriptquo,项目名称:pventa,代码行数:11,代码来源:rest.py

示例13: get_agency

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
def get_agency(user=None):
    from agencies.models import Agency
    if not user:
        user = CuserMiddleware.get_user()
    try:
        agency = user.agent_profile.agency
    except:
        agency = Agency.objects.get(id=settings.DEFAULT_AGENCY_ID)
    return agency
开发者ID:kornelpro51,项目名称:FMG2013,代码行数:11,代码来源:models.py

示例14: get_queryset

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
 def get_queryset(self):
     qs = super(NoteViewSet, self).get_queryset()
     user = CuserMiddleware.get_user()
     if user:
         if user.is_superuser:
             return qs
         else:
             return qs.filter(agency=get_agency())
     else:
         return qs.filter(agency=get_agency())
开发者ID:kornelpro51,项目名称:FMG2013,代码行数:12,代码来源:api.py

示例15: get_query_set

# 需要导入模块: from cuser.middleware import CuserMiddleware [as 别名]
# 或者: from cuser.middleware.CuserMiddleware import get_user [as 别名]
 def get_query_set(self):
     qs = super(AgencyIsolatedHstoreManager, self).get_query_set()
     user = CuserMiddleware.get_user()
     if user:
         if user.is_superuser:
             return qs
         else:
             return qs.filter(agency=get_agency())
     else:
         return qs.filter(agency=get_agency())
开发者ID:kornelpro51,项目名称:FMG2013,代码行数:12,代码来源:models.py


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