Esempio n. 1
0
def add_application_to_database(request):
    """ Adds app info only to Django database """

    if request.is_ajax() and utils.application_url_correct(request.POST['aps_url']):
        url = request.POST['aps_url']
        app_meta_url = utils.get_appmeta_url(url)
        app_meta_parsed = utils.get_app_meta_parsed(app_meta_url)
        app_attributes = utils.get_application_attributes(app_meta_parsed)
        if app_attributes is not None and not Application.objects.filter(**app_attributes).exists():
            app_attributes.update({'url': url})
            response = {'status': 0, 'result': 'Application added successfully'}
            Application.objects.create(**app_attributes)
        else:
            response = {'status': 1, 'result': 'Application cannot be added'}
    else:
        response = {'status': 1, 'result': 'Application cannot be added'}
    return HttpResponse(json.dumps(response), content_type='application/json')
Esempio n. 2
0
def add_application_to_database(request):
    """ Adds app info only to Django database """

    if request.is_ajax() and utils.application_url_correct(
            request.POST['aps_url']):
        url = request.POST['aps_url']
        app_meta_url = utils.get_appmeta_url(url)
        app_meta_parsed = utils.get_app_meta_parsed(app_meta_url)
        app_attributes = utils.get_application_attributes(app_meta_parsed)
        if app_attributes is not None and not Application.objects.filter(
                **app_attributes).exists():
            app_attributes.update({'url': url})
            response = {
                'status': 0,
                'result': 'Application added successfully'
            }
            Application.objects.create(**app_attributes)
        else:
            response = {'status': 1, 'result': 'Application cannot be added'}
    else:
        response = {'status': 1, 'result': 'Application cannot be added'}
    return HttpResponse(json.dumps(response), content_type='application/json')
Esempio n. 3
0
    def test_get_appmeta_parsed(self):
        """ Testing ElementTree object retrieving from XML """

        url1 = 'https://apscatalog.com/storage/Zen%20Cart/Zen%20Cart/1.5.3-5/GlowTouch%20Technologies/undefined/undefined/undefined/resources/APP-META.xml'
        utils.urllib2.urlopen = dummy_appmeta_url
        self.assertEqual(isinstance(utils.get_app_meta_parsed(url1), ET), True)