Exemplo n.º 1
0
def __map_info_from_objects(request, map_objects, yaml):
    results = {}
    for map_object in map_objects:
        last_revision = True
        if map_object.next_rev != 0:
            last_revision = False

        license_label, _ = misc.selectLicenceInfo(map_object)
        if license_label is not None:
            license_label = "Creative Commons " + license_label
        else:
            license_label = "null"

        # TODO: Read this from the mod id / parser model once this has been added
        map_grid_type = 'Rectangular'  # ra/cnc/d2k
        if map_object.game_mod in ['ts', 'ra2', 'sp']:
            map_grid_type = 'RectangularIsometric'

        # TODO: Reimplement categories in a nicer way
        category_list = []
        if map_object.categories:
            categories = json.loads(map_object.categories)
            category_ids = [cat_id.strip('_') for cat_id in categories]
            category_objects = MapCategories.objects.filter(
                id__in=category_ids)
            category_list = [
                html.escape(c.category_name) for c in category_objects
            ]

        minimap_path = os.path.join(settings.BASE_DIR, 'openra', 'data',
                                    'maps', str(map_object.id), 'content',
                                    'map.png')

        if os.path.exists(minimap_path):
            with open(minimap_path, 'rb') as image_file:
                minimap = base64.b64encode(image_file.read()).decode()
        else:
            minimap = ''

        download_url = 'http://' + request.META['HTTP_HOST'] + \
                       '/maps/' + str(map_object.id) + '/oramap'

        results[map_object.map_hash] = {
            'id': map_object.id,
            'title': html.escape(map_object.title),
            'description': html.escape(map_object.description),
            'info': html.escape(map_object.info),
            'author': html.escape(map_object.author),
            'map_type': html.escape(map_object.map_type),
            'players': map_object.players,
            'game_mod': html.escape(map_object.game_mod),
            'map_hash': map_object.map_hash,
            'width': map_object.width,
            'height': map_object.height,
            'bounds': map_object.bounds,
            'spawnpoints': map_object.spawnpoints,
            'tileset': html.escape(map_object.tileset),
            'revision': map_object.revision,
            'last_revision': last_revision,
            'requires_upgrade': map_object.requires_upgrade,
            'advanced_map': map_object.advanced_map,
            'lua': map_object.lua,
            'posted': str(map_object.posted),
            'viewed': map_object.viewed,
            'downloaded': map_object.downloaded,
            'rating': map_object.rating,
            'license': license_label,
            'minimap': minimap,
            'url': download_url,
            'downloading': map_object.downloading,
            'mapformat': map_object.mapformat,
            'parser': map_object.parser,
            'map_grid_type': map_grid_type,
            'categories': category_list,
            'rules': map_object.base64_rules,
            'players_block': map_object.base64_players,
            'reports': map_object.amount_reports,
        }

    return __generate_response(results, yaml)
Exemplo n.º 2
0
def displayMap(request, arg):
    if request.method == 'POST':
        if request.POST.get('reportReason', "").strip() != "":
            checkReports = Reports.objects.filter(user_id=request.user.id,
                                                  ex_id=arg,
                                                  ex_name='maps')
            if not checkReports:
                checkReports = Reports.objects.filter(ex_id=arg,
                                                      ex_name='maps')
                infringement = request.POST.get('infringement', False)
                if infringement == "true":
                    infringement = True
                transac = Reports(
                    user_id=request.user.id,
                    reason=request.POST['reportReason'].strip(),
                    ex_id=arg,
                    ex_name='maps',
                    infringement=infringement,
                    posted=timezone.now(),
                )
                transac.save()
                Maps.objects.filter(id=arg).update(
                    amount_reports=F('amount_reports') + 1)
                misc.send_email_to_admin_OnReport({
                    'addr':
                    request.META['HTTP_HOST'] + '/maps/' + arg,
                    'user_id':
                    request.user.id,
                    'reason':
                    request.POST['reportReason'].strip(),
                    'infringement':
                    infringement
                })
                misc.send_email_to_user_OnReport({
                    'addr':
                    request.META['HTTP_HOST'] + '/maps/' + arg,
                    'owner_id':
                    Maps.objects.get(id=arg).user_id,
                    'reason':
                    request.POST['reportReason'].strip(),
                    'resource_type':
                    'map'
                })
                return HttpResponseRedirect('/maps/' + arg)
        elif request.POST.get('mapInfo', False) is not False:
            if request.user.is_superuser:
                Maps.objects.filter(id=arg).update(
                    info=request.POST['mapInfo'].strip())
            else:
                Maps.objects.filter(id=arg, user_id=request.user.id).update(
                    info=request.POST['mapInfo'].strip())
            return HttpResponseRedirect('/maps/' + arg)
        elif request.FILES.get('screenshot', False) is not False:

            handlers.addScreenshot(request, arg, 'map')

        elif request.POST.get('comment', "") != "":
            transac = Comments(
                item_type='maps',
                item_id=int(arg),
                user=request.user,
                content=request.POST['comment'].strip(),
                posted=timezone.now(),
                is_removed=False,
            )
            transac.save()

            commented_map_obj = Maps.objects.get(id=arg)
            if commented_map_obj.user != request.user:
                misc.send_email_to_user_OnComment('maps',
                                                  arg,
                                                  commented_map_obj.user.email,
                                                  info="owner")

            comsObj = Comments.objects.filter(item_type='maps',
                                              item_id=arg,
                                              is_removed=False)
            if comsObj:
                for com in comsObj:
                    if com.user != request.user and com.user != commented_map_obj.user:

                        unsubObj = UnsubscribeComments.objects.filter(
                            item_type='maps', item_id=arg, user=com.user)

                        if not unsubObj:
                            misc.send_email_to_user_OnComment(
                                'maps', arg, com.user.email)

            return HttpResponseRedirect('/maps/' + arg + '/')

    contains_shp = False
    disk_size = 0
    path = os.path.join(settings.BASE_DIR,
                        __name__.split('.')[0], 'data', 'maps', arg)
    try:
        mapDir = os.listdir(path)
        for filename in mapDir:
            if filename.endswith(".oramap"):
                disk_size = os.path.getsize(os.path.join(path, filename))
                disk_size = misc.sizeof_fmt(disk_size)
                break
        mapDir = os.listdir(os.path.join(path, 'content'))
        for filename in mapDir:
            if filename.endswith(".shp"):
                contains_shp = True
                break
    except FileNotFoundError as ex:
        print(ex)
        return HttpResponseRedirect('/')
    try:
        mapObject = Maps.objects.get(id=arg)
    except:
        return HttpResponseRedirect('/')

    lints = []
    lintObject = Lints.objects.filter(map_id=mapObject.id, item_type='maps')
    lintObject = sorted(lintObject, key=lambda x: (x.posted), reverse=False)
    for lint_item in lintObject:
        lints.append([
            lint_item.version_tag, lint_item.pass_status, lint_item.lint_output
        ])

    reportedByUser = False
    reports = []
    reportObject = Reports.objects.filter(ex_id=mapObject.id, ex_name='maps')
    for item in reportObject:
        try:
            usr = User.objects.get(pk=item.user_id)
            reports.append(
                [usr.username, item.reason, item.infringement, item.posted])
        except:
            pass
        if item.user_id == request.user.id:
            reportedByUser = True

    luaNames = []

    listContent = os.listdir(os.path.join(path, 'content'))

    for fn in listContent:
        if fn.endswith('.lua'):
            luaNames.append(os.path.splitext(fn)[0])

    shpNames = []
    for fn in listContent:
        if fn.endswith('.shp.gif'):
            shpNames.append(fn.split('.shp.gif')[0])

    mapsFromAuthor = Maps.objects.filter(
        author=mapObject.author,
        next_rev=0).exclude(id=mapObject.id).distinct('map_hash').order_by(
            'map_hash', '-posted').exclude(map_hash=mapObject.map_hash)
    if len(mapsFromAuthor) >= 8:
        mapsFromAuthor = random.sample(list(mapsFromAuthor), 8)
    else:
        mapsFromAuthor = random.sample(list(mapsFromAuthor),
                                       len(mapsFromAuthor))

    similarMaps = Maps.objects.filter(
        next_rev=0,
        game_mod=mapObject.game_mod,
        tileset=mapObject.tileset,
        players=mapObject.players,
        map_type=mapObject.map_type,
        width=mapObject.width,
        height=mapObject.height).exclude(map_hash=mapObject.map_hash)[0:8]

    duplicates = Maps.objects.filter(map_hash=mapObject.map_hash).exclude(
        id=mapObject.id)
    if duplicates:
        duplicates = True

    screenshots = Screenshots.objects.filter(ex_name="maps", ex_id=arg)

    try:
        played_counter = urllib.request.urlopen(
            "http://master.openra.net/map_stats?hash=%s" %
            mapObject.map_hash).read().decode()
        played_counter = json.loads(played_counter)
        if played_counter:
            played_counter = played_counter["played"]
        else:
            played_counter = 0
    except:
        played_counter = 'unknown'

    ratesAmount = Rating.objects.filter(ex_id=mapObject.id, ex_name='map')
    ratesAmount = len(ratesAmount)

    comments = misc.get_comments_for_all_revisions(request, 'maps', arg)

    # showing upgrade map button
    show_upgrade_map_button = True

    if not (request.user == mapObject.user or request.user.is_superuser):
        show_upgrade_map_button = False

    if 'git' in mapObject.parser:
        show_upgrade_map_button = False  # can't upgrade maps uploaded with bleed parser
    if mapObject.next_rev != 0:
        show_upgrade_map_button = False  # upgrade only the latest revision

    if mapObject.parser == list(
            reversed(list(settings.OPENRA_VERSIONS.values())))[0]:
        show_upgrade_map_button = False  # map is up-to-date
    ###

    map_preview = None
    for sc_item in screenshots:
        if sc_item.map_preview:
            map_preview = sc_item

    last_parser = list(reversed(list(settings.OPENRA_VERSIONS.values())))[0]

    license, icons = misc.selectLicenceInfo(mapObject)
    userObject = User.objects.get(pk=mapObject.user_id)
    Maps.objects.filter(id=mapObject.id).update(viewed=mapObject.viewed + 1)

    template = loader.get_template('index.html')
    template_args = {
        'content': 'displayMap.html',
        'request': request,
        'title': ' - Map details - ' + mapObject.title,
        'map': mapObject,
        'userid': userObject,
        'arg': arg,
        'license': license,
        'icons': icons,
        'reports': reports,
        'reported': reportedByUser,
        'luaNames': luaNames,
        'mapsFromAuthor': mapsFromAuthor,
        'similarMaps': similarMaps,
        'screenshots': screenshots,
        'shpNames': shpNames,
        'disk_size': disk_size,
        'duplicates': duplicates,
        'played_counter': played_counter,
        'ratesAmount': ratesAmount,
        'REPORTS_PENALTY_AMOUNT': settings.REPORTS_PENALTY_AMOUNT,
        'lints': lints,
        'comments': comments,
        'show_upgrade_map_button': show_upgrade_map_button,
        'map_preview': map_preview,
        'contains_shp': contains_shp,
        'last_parser': last_parser,
    }
    return StreamingHttpResponse(template.render(template_args, request))
Exemplo n.º 3
0
def serialize_basic_map_info(request, mapObject, yaml=""):
    minimap = get_minimap(mapObject.id, True)
    url = get_url(request, mapObject.id)
    last_revision = True
    if mapObject.next_rev != 0:
        last_revision = False
    license, icons = misc.selectLicenceInfo(mapObject)
    if license is not None:
        license = "Creative Commons " + license
    else:
        license = "null"

    map_grid_type = 'Rectangular'  # ra/cnc/d2k
    if mapObject.game_mod in ['ts', 'ra2']:
        map_grid_type = 'RectangularIsometric'

    category_lst = []
    if mapObject.categories:
        categories = json.loads(mapObject.categories)
        for cat_id in categories:
            catObj = MapCategories.objects.filter(id=cat_id.strip('_')).first()
            if catObj:
                category_lst.append(catObj.category_name)

    if yaml:
        response_data = u"""
{0}:
\tid: {1}
\ttitle: {2}
\tdescription: {3}
\tauthor: {4}
\tmap_type: {5}
\tplayers: {6}
\tgame_mod: {7}
\twidth: {8}
\theight: {9}
\tbounds: {10}
\tspawnpoints: {11}
\ttileset: {12}
\trevision: {13}
\tlast_revision: {14}
\trequires_upgrade: {15}
\tadvanced_map: {16}
\tlua: {17}
\tposted: {18}
\tviewed: {19}
\tdownloaded: {20}
\trating: {21}
\tlicense: {22}
\tminimap: {23}
\turl: {24}
\tdownloading: {25}
\tmapformat: {26}
\tparser: {27}
\tmap_grid_type: {28}
\tcategories: {29}
\trules: {30}
\tplayers_block: {31}
\treports: {32}\n""".format(
            mapObject.map_hash,
            mapObject.id,
            cgi.escape(mapObject.title, quote=None),
            cgi.escape(mapObject.description, quote=None),
            cgi.escape(mapObject.author.encode('utf-8').decode('utf-8'), quote=None),
            cgi.escape(mapObject.map_type, quote=None),
            mapObject.players,
            cgi.escape(mapObject.game_mod, quote=None),
            mapObject.width,
            mapObject.height,
            mapObject.bounds,
            mapObject.spawnpoints,
            cgi.escape(mapObject.tileset, quote=None),
            mapObject.revision,
            last_revision,
            mapObject.requires_upgrade,
            mapObject.advanced_map,
            mapObject.lua,
            str(mapObject.posted),
            mapObject.viewed,
            mapObject.downloaded,
            mapObject.rating,
            license,
            minimap,
            url,
            mapObject.downloading,
            mapObject.mapformat,
            mapObject.parser,
            map_grid_type,
            cgi.escape(", ".join(category_lst), quote=None),
            mapObject.base64_rules,
            mapObject.base64_players,
            mapObject.amount_reports
        ).replace("''", "'").lstrip()
        return response_data
    response_data = {}
    response_data['id'] = mapObject.id
    response_data['title'] = cgi.escape(mapObject.title, quote=None).replace("''", "'")
    response_data['description'] = cgi.escape(mapObject.description, quote=None).replace("''", "'")
    response_data['info'] = cgi.escape(mapObject.info, quote=None).replace("''", "'")
    response_data['author'] = cgi.escape(mapObject.author, quote=None).replace("''", "'")
    response_data['map_type'] = cgi.escape(mapObject.map_type, quote=None).replace("''", "'")
    response_data['players'] = mapObject.players
    response_data['game_mod'] = cgi.escape(mapObject.game_mod, quote=None).replace("''", "'")
    response_data['map_hash'] = mapObject.map_hash
    response_data['width'] = mapObject.width
    response_data['height'] = mapObject.height
    response_data['bounds'] = mapObject.bounds
    response_data['spawnpoints'] = mapObject.spawnpoints
    response_data['tileset'] = cgi.escape(mapObject.tileset, quote=None)
    response_data['revision'] = mapObject.revision
    response_data['last_revision'] = last_revision
    response_data['requires_upgrade'] = mapObject.requires_upgrade
    response_data['advanced_map'] = mapObject.advanced_map
    response_data['lua'] = mapObject.lua
    response_data['posted'] = str(mapObject.posted)
    response_data['viewed'] = mapObject.viewed
    response_data['downloaded'] = mapObject.downloaded
    response_data['rating'] = mapObject.rating
    response_data['license'] = license
    response_data['minimap'] = minimap
    response_data['url'] = url
    response_data['downloading'] = mapObject.downloading
    response_data['mapformat'] = mapObject.mapformat
    response_data['parser'] = mapObject.parser
    response_data['map_grid_type'] = map_grid_type
    response_data['categories'] = category_lst
    response_data['rules'] = mapObject.base64_rules
    response_data['players_block'] = mapObject.base64_players
    response_data['reports'] = mapObject.amount_reports
    return response_data
Exemplo n.º 4
0
def displayMap(request, arg):
    if request.method == 'POST':
        if request.POST.get('reportReason', "").strip() != "":
            checkReports = Reports.objects.filter(user_id=request.user.id, ex_id=arg, ex_name='maps')
            if not checkReports:
                checkReports = Reports.objects.filter(ex_id=arg, ex_name='maps')
                infringement = request.POST.get('infringement', False)
                if infringement == "true":
                    infringement = True
                transac = Reports(
                    user_id=request.user.id,
                    reason=request.POST['reportReason'].strip(),
                    ex_id=arg,
                    ex_name='maps',
                    infringement=infringement,
                    posted=timezone.now(),
                )
                transac.save()
                Maps.objects.filter(id=arg).update(amount_reports=F('amount_reports')+1)
                misc.send_email_to_admin_OnReport({'addr': request.META['HTTP_HOST']+'/maps/'+arg, 'user_id': request.user.id, 'reason': request.POST['reportReason'].strip(), 'infringement': infringement})
                misc.send_email_to_user_OnReport({'addr': request.META['HTTP_HOST']+'/maps/'+arg, 'owner_id': Maps.objects.get(id=arg).user_id, 'reason': request.POST['reportReason'].strip(), 'resource_type': 'map'})
                return HttpResponseRedirect('/maps/'+arg)
        elif request.POST.get('mapInfo', False) is not False:
            if request.user.is_superuser:
                Maps.objects.filter(id=arg).update(info=request.POST['mapInfo'].strip())
            else:
                Maps.objects.filter(id=arg, user_id=request.user.id).update(info=request.POST['mapInfo'].strip())
            return HttpResponseRedirect('/maps/'+arg)
        elif request.FILES.get('screenshot', False) is not False:

                handlers.addScreenshot(request, arg, 'map')

        elif request.POST.get('comment', "") != "":
            transac = Comments(
                item_type='maps',
                item_id=int(arg),
                user=request.user,
                content=request.POST['comment'].strip(),
                posted=timezone.now(),
                is_removed=False,
            )
            transac.save()

            commented_map_obj = Maps.objects.get(id=arg)
            if commented_map_obj.user != request.user:
                misc.send_email_to_user_OnComment('maps', arg, commented_map_obj.user.email, info="owner")

            comsObj = Comments.objects.filter(item_type='maps', item_id=arg, is_removed=False)
            if comsObj:
                for com in comsObj:
                    if com.user != request.user and com.user != commented_map_obj.user:

                        unsubObj = UnsubscribeComments.objects.filter(item_type='maps', item_id=arg, user=com.user)

                        if not unsubObj:
                            misc.send_email_to_user_OnComment('maps', arg, com.user.email)

            return HttpResponseRedirect('/maps/' + arg + '/')

    contains_shp = False
    disk_size = 0
    path = os.getcwd() + os.sep + __name__.split('.')[0] + '/data/maps/' + arg
    try:
        mapDir = os.listdir(path)
        for filename in mapDir:
            if filename.endswith(".oramap"):
                disk_size = os.path.getsize(path + '/' + filename)
                disk_size = misc.sizeof_fmt(disk_size)
                break
        mapDir = os.listdir(path + '/content/')
        for filename in mapDir:
            if filename.endswith(".shp"):
                contains_shp = True
                break
    except FileNotFoundError as ex:
        print(ex)
        return HttpResponseRedirect('/')
    try:
        mapObject = Maps.objects.get(id=arg)
    except:
        return HttpResponseRedirect('/')

    lints = []
    lintObject = Lints.objects.filter(map_id=mapObject.id, item_type='maps')
    lintObject = sorted(lintObject, key=lambda x: (x.posted), reverse=False)
    for lint_item in lintObject:
        lints.append([lint_item.version_tag, lint_item.pass_status, lint_item.lint_output])

    reportedByUser = False
    reports = []
    reportObject = Reports.objects.filter(ex_id=mapObject.id, ex_name='maps')
    for item in reportObject:
        try:
            usr = User.objects.get(pk=item.user_id)
            reports.append([usr.username, item.reason, item.infringement, item.posted])
        except:
            pass
        if item.user_id == request.user.id:
            reportedByUser = True

    luaNames = []

    listContent = os.listdir(path + '/content/')

    for fn in listContent:
        if fn.endswith('.lua'):
            luaNames.append(os.path.splitext(fn)[0])

    shpNames = []
    for fn in listContent:
        if fn.endswith('.shp.gif'):
            shpNames.append(fn.split('.shp.gif')[0])

    mapsFromAuthor = Maps.objects.filter(author=mapObject.author, next_rev=0).exclude(id=mapObject.id).distinct('map_hash').order_by('map_hash', '-posted').exclude(map_hash=mapObject.map_hash)
    if len(mapsFromAuthor) >= 8:
        mapsFromAuthor = random.sample(list(mapsFromAuthor), 8)
    else:
        mapsFromAuthor = random.sample(list(mapsFromAuthor), len(mapsFromAuthor))

    similarMaps = Maps.objects.filter(next_rev=0, game_mod=mapObject.game_mod, tileset=mapObject.tileset, players=mapObject.players, map_type=mapObject.map_type, width=mapObject.width, height=mapObject.height).exclude(map_hash=mapObject.map_hash)[0:8]

    duplicates = Maps.objects.filter(map_hash=mapObject.map_hash).exclude(id=mapObject.id)
    if duplicates:
        duplicates = True

    screenshots = Screenshots.objects.filter(ex_name="maps", ex_id=arg)

    try:
        played_counter = urllib.request.urlopen("http://master.openra.net/map_stats?hash=%s" % mapObject.map_hash).read().decode()
        played_counter = json.loads(played_counter)
        if played_counter:
            played_counter = played_counter["played"]
        else:
            played_counter = 0
    except:
        played_counter = 'unknown'

    ratesAmount = Rating.objects.filter(ex_id=mapObject.id, ex_name='map')
    ratesAmount = len(ratesAmount)

    comments = misc.get_comments_for_all_revisions(request, 'maps', arg)

    # showing upgrade map button
    show_upgrade_map_button = True

    if not (request.user == mapObject.user or request.user.is_superuser):
        show_upgrade_map_button = False

    if 'git' in mapObject.parser:
        show_upgrade_map_button = False  # can't upgrade maps uploaded with bleed parser
    if mapObject.next_rev != 0:
        show_upgrade_map_button = False  # upgrade only the latest revision

    if mapObject.parser == list(reversed(list(settings.OPENRA_VERSIONS.values())))[0]:
        show_upgrade_map_button = False  # map is up-to-date
    ###

    map_preview = None
    for sc_item in screenshots:
        if sc_item.map_preview:
            map_preview = sc_item

    last_parser = list(reversed(list(settings.OPENRA_VERSIONS.values())))[0]

    license, icons = misc.selectLicenceInfo(mapObject)
    userObject = User.objects.get(pk=mapObject.user_id)
    Maps.objects.filter(id=mapObject.id).update(viewed=mapObject.viewed+1)

    template = loader.get_template('index.html')
    template_args = {
        'content': 'displayMap.html',
        'request': request,
        'title': ' - Map details - ' + mapObject.title,
        'map': mapObject,
        'userid': userObject,
        'arg': arg,
        'license': license,
        'icons': icons,
        'reports': reports,
        'reported': reportedByUser,
        'luaNames': luaNames,
        'mapsFromAuthor': mapsFromAuthor,
        'similarMaps': similarMaps,
        'screenshots': screenshots,
        'shpNames': shpNames,
        'disk_size': disk_size,
        'duplicates': duplicates,
        'played_counter': played_counter,
        'ratesAmount': ratesAmount,
        'REPORTS_PENALTY_AMOUNT': settings.REPORTS_PENALTY_AMOUNT,
        'lints': lints,
        'comments': comments,
        'show_upgrade_map_button': show_upgrade_map_button,
        'map_preview': map_preview,
        'contains_shp': contains_shp,
        'last_parser': last_parser,
    }
    return StreamingHttpResponse(template.render(template_args, request))
Exemplo n.º 5
0
def serialize_basic_map_info(request, mapObject, yaml=""):
    minimap = get_minimap(mapObject.id, True)
    url = get_url(request, mapObject.id)
    last_revision = True
    if mapObject.next_rev != 0:
        last_revision = False
    license, icons = misc.selectLicenceInfo(mapObject)
    if license is not None:
        license = "Creative Commons " + license
    else:
        license = "null"

    map_grid_type = 'Rectangular'  # ra/cnc/d2k
    if mapObject.game_mod in ['ts', 'ra2']:
        map_grid_type = 'RectangularIsometric'

    category_lst = []
    if mapObject.categories:
        categories = json.loads(mapObject.categories)
        for cat_id in categories:
            catObj = MapCategories.objects.filter(id=cat_id.strip('_')).first()
            if catObj:
                category_lst.append(catObj.category_name)

    if yaml:
        response_data = u"""
{0}:
\tid: {1}
\ttitle: {2}
\tdescription: {3}
\tauthor: {4}
\tmap_type: {5}
\tplayers: {6}
\tgame_mod: {7}
\twidth: {8}
\theight: {9}
\tbounds: {10}
\tspawnpoints: {11}
\ttileset: {12}
\trevision: {13}
\tlast_revision: {14}
\trequires_upgrade: {15}
\tadvanced_map: {16}
\tlua: {17}
\tposted: {18}
\tviewed: {19}
\tdownloaded: {20}
\trating: {21}
\tlicense: {22}
\tminimap: {23}
\turl: {24}
\tdownloading: {25}
\tmapformat: {26}
\tparser: {27}
\tmap_grid_type: {28}
\tcategories: {29}
\trules: {30}
\tplayers_block: {31}
\treports: {32}\n""".format(
            mapObject.map_hash, mapObject.id,
            cgi.escape(mapObject.title, quote=None),
            cgi.escape(mapObject.description, quote=None),
            cgi.escape(mapObject.author.encode('utf-8').decode('utf-8'),
                       quote=None), cgi.escape(mapObject.map_type,
                                               quote=None), mapObject.players,
            cgi.escape(mapObject.game_mod, quote=None), mapObject.width,
            mapObject.height, mapObject.bounds, mapObject.spawnpoints,
            cgi.escape(mapObject.tileset,
                       quote=None), mapObject.revision, last_revision,
            mapObject.requires_upgrade, mapObject.advanced_map, mapObject.lua,
            str(mapObject.posted), mapObject.viewed, mapObject.downloaded,
            mapObject.rating, license, minimap, url, mapObject.downloading,
            mapObject.mapformat, mapObject.parser, map_grid_type,
            cgi.escape(", ".join(category_lst), quote=None),
            mapObject.base64_rules, mapObject.base64_players,
            mapObject.amount_reports).replace("''", "'").lstrip()
        return response_data
    response_data = {}
    response_data['id'] = mapObject.id
    response_data['title'] = cgi.escape(mapObject.title,
                                        quote=None).replace("''", "'")
    response_data['description'] = cgi.escape(mapObject.description,
                                              quote=None).replace("''", "'")
    response_data['info'] = cgi.escape(mapObject.info,
                                       quote=None).replace("''", "'")
    response_data['author'] = cgi.escape(mapObject.author,
                                         quote=None).replace("''", "'")
    response_data['map_type'] = cgi.escape(mapObject.map_type,
                                           quote=None).replace("''", "'")
    response_data['players'] = mapObject.players
    response_data['game_mod'] = cgi.escape(mapObject.game_mod,
                                           quote=None).replace("''", "'")
    response_data['map_hash'] = mapObject.map_hash
    response_data['width'] = mapObject.width
    response_data['height'] = mapObject.height
    response_data['bounds'] = mapObject.bounds
    response_data['spawnpoints'] = mapObject.spawnpoints
    response_data['tileset'] = cgi.escape(mapObject.tileset, quote=None)
    response_data['revision'] = mapObject.revision
    response_data['last_revision'] = last_revision
    response_data['requires_upgrade'] = mapObject.requires_upgrade
    response_data['advanced_map'] = mapObject.advanced_map
    response_data['lua'] = mapObject.lua
    response_data['posted'] = str(mapObject.posted)
    response_data['viewed'] = mapObject.viewed
    response_data['downloaded'] = mapObject.downloaded
    response_data['rating'] = mapObject.rating
    response_data['license'] = license
    response_data['minimap'] = minimap
    response_data['url'] = url
    response_data['downloading'] = mapObject.downloading
    response_data['mapformat'] = mapObject.mapformat
    response_data['parser'] = mapObject.parser
    response_data['map_grid_type'] = map_grid_type
    response_data['categories'] = category_lst
    response_data['rules'] = mapObject.base64_rules
    response_data['players_block'] = mapObject.base64_players
    response_data['reports'] = mapObject.amount_reports
    return response_data