Пример #1
0
def getManufacturerInfo(name):
    """
    getManufacturerInfo(name) -> Return a dictionary with all the information
                                related to the specified manufacturer
    """
    manufacturer = models.Manufacturer.objects.get(pk=name)

    manu_info = {
        "name": manufacturer.name,
        "desc": manufacturer.desc,
        "link": {"rel": "self", "href": getManufacturerURL(manufacturer.name)},
        "makes": [],
    }

    # Try to add links of made components
    components = getManufacturerComponents(manufacturer)

    for c in components:
        manu_info["makes"].append({"name": c.name, "link": getComponentURL(c.name)})

    # Try to add links of made operating systems
    operating_systems = getManufacturerOperatingSystems(manufacturer)

    for os in operating_systems:
        manu_info["makes"].append({"name": os.name, "link": getOperatingSystemURL(os.name)})

    return manu_info
Пример #2
0
 def get(self, request, *args, **kwargs):
     try:
         context = self.get_context_data(**kwargs)
         return self.render_to_response(context)
     except ObjectDoesNotExist, e:
         name = kwargs['name']
         return responseutils.getHttpResponseNotFoundHTML(
                                     '%s Not Found' % name,
                                     request.user,
                                     name,
                                     urlutils.getOperatingSystemURL(name))
Пример #3
0
def getOSsInfoAsList():
    """
    getOSInfoAsList() -> Return a list filled with dictionaries
                                containing OS information
    """

    os_info = []

    for os in models.OperatingSystem.objects.all():
        os = {"name": os.name, "link": {"rel": "self", "href": getOperatingSystemURL(os.name)}}

        os_info.append(os)

    return os_info
Пример #4
0
def getOSInfo(name):
    """
    getOSInfo(name) -> Return a dictionary with all the information
                            of the specified OS
    """

    print name
    os = models.OperatingSystem.objects.get(pk=name)
    os_info = {"name": os.name, "manufacturer": "", "link": {"rel": "self", "href": getOperatingSystemURL(os.name)}}

    manufacturer = getOSManufacturer(os)
    if manufacturer:
        os_info["manufacturer"] = {"name": manufacturer.name, "link": getManufacturerURL(manufacturer.name)}

    return os_info
Пример #5
0
def getComponentInfo(ref):
    """
    getComponentInfo(ref) -> Return a dictionary with all the information
                            of the specified component
    """
    comp = models.Component.objects.get(pk=ref)

    cinf = {
        "ref": comp.ref,
        "name": comp.name,
        "img": str(comp.img),
        "avgprice": str(comp.avgprice),
        "category": {
            "name": str(comp.category) if comp.category else "",
            "link": getCategoryURL(comp.category.name) if comp.category else "",
        },
        "desc": comp.desc,
        "manufacturer": {
            "name": str(comp.manufacturer) if comp.manufacturer else "",
            "link": getManufacturerURL(comp.manufacturer.name) if comp.manufacturer else "",
        },
        "supportedby": [],
        "createdby": str(comp.createdby),
        "link": {"rel": "self", "href": getComponentURL(comp.ref)},
    }

    # Add supported by list if exists (elements separed by ;)
    supportedby = getComponentSupportedBy(comp)

    if supportedby:
        for sb in supportedby:
            cinf["supportedby"].append(
                {
                    "id": sb["id"],
                    "name": sb["name"],
                    "link": getOperatingSystemURL(sb["name"]),
                    "minversion": sb["minversion"],
                    "maxversion": sb["maxversion"],
                }
            )

    # Add reviews
    cinf["reviews"] = getComponentReviews(comp)

    return cinf