Пример #1
0
    def test_get_appmeta_url(self):
        """ test getting URL of APP-META.xml """

        url1 = 'https://apscatalog.com/storage/Hostway/ESC-SKIN/3.0.16-1/Hostway/undefined/undefined/undefined/ESC-SKIN-3.0.16-1.app.zip'
        url2 = 'https://apscatalog.com/storage/Zen%20Cart/Zen%20Cart/1.5.3-5/GlowTouch%20Technologies/undefined/undefined/undefined/ZenCart-1.5.3-5.app.zip'
        appmeta1 = 'https://apscatalog.com/storage/Hostway/ESC-SKIN/3.0.16-1/Hostway/undefined/undefined/undefined/resources/APP-META.xml'
        appmeta2 = 'https://apscatalog.com/storage/Zen%20Cart/Zen%20Cart/1.5.3-5/GlowTouch%20Technologies/undefined/undefined/undefined/resources/APP-META.xml'
        self.assertEqual(utils.get_appmeta_url(url1), appmeta1)
        self.assertEqual(utils.get_appmeta_url(url2), appmeta2)
Пример #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')
Пример #3
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')