# -*- coding: utf-8 -*-

from curtail_uuid import CurtailUUID
from django.conf import settings

from photo.models import UUIDInfo
from utils.redis.rkeys import UUID_LIST


r = settings.REDIS_CACHE


def generate_uuid():
    uuid = CurtailUUID.uuid(UUIDInfo)
    UUIDInfo.objects.create(uuid=uuid)
    return uuid


def generate_uuids(num=1000):
    uuids = [generate_uuid() for i in xrange(num)]
    r.rpush(UUID_LIST, *uuids)


def update_uuids(lensman_id, uuids):
    UUIDInfo.objects.filter(uuid__in=uuids).update(lensman_id=lensman_id, status=False)
