Exemplo n.º 1
0
def setGlobalProperty(name="", value=0):
    """
    """
    try:
        try:
            un = GlobalProperty.objects.get(name=name)
            un.value = value
        except GlobalProperty.DoesNotExist:
            un = GlobalProperty(name=name, value=value)
        un.save()
        return True
    except:
        return False
Exemplo n.º 2
0
def incGlobalProperty(name="", incrementBy=1):
    """Increments value Field by given value, creates Property if DoesNotExist
    """
    try:
        try:
            un = GlobalProperty.objects.get(name=name)
        except GlobalProperty.DoesNotExist:
            un = GlobalProperty(name=name, value=0)

        un.value += incrementBy
        un.save()
        return True
    except:
        return False
Exemplo n.º 3
0
def decGlobalProperty(name="", decrementBy=1):
    """Decrements value Field by given value, creates Property if DoesNotExist
    """
    try:
        try:
            un = GlobalProperty.objects.get(name=name)
        except GlobalProperty.DoesNotExist:
            un = GlobalProperty(name=name, value=0)
        if un.value < 1:
            pass
        else:
            un.value -= decrementBy
            un.save()
        return True
    except:
        return False