Пример #1
0
def mucua_list(request, repository=None):
    """
    List all mucuas
    """

    logger.debug(_(u"Acessing mucuas in repository: %s") % repository)

    if repository:
        try:
            repository = Repository.objects.get(name=repository)
        except Repository.DoesNotExist:
            return Response("Repository not found")

    mucuas = get_available_mucuas(None, repository)  # retorna tupla de mucuas
    mucuas_list = []

    if mucuas is None:
        return Response(None)

    for mucua_obj in mucuas:
        if mucua_obj[1] != 'web':
            mucua_description = mucua_obj[1]
            try:
                mucua = Mucua.objects.get(description=mucua_description)
            except Mucua.DoesNotExist:
                return Response("Mucua not found")

            if mucua:
                mucuas_list.append(mucua)

    serializer = MucuaSerializer(mucuas_list, many=True)

    return Response(serializer.data)
Пример #2
0
def mucua_get_by_name(request, name, repository=None):
    try:     
        mucua = Mucua.objects.get(description=name)
    except:
        return Response(_("Mucua not found"))
    
    serializer = MucuaSerializer(mucua, many=False)
    
    return Response(serializer.data)
Пример #3
0
def mucua_get_default(request):
    mucuas_list = []
    mucuas_list.append(get_default_mucua())
    serializer = MucuaSerializer(mucuas_list, many=True)

    return Response(serializer.data)