<commit_before># -*- coding: utf-8 -*-

import openerp
from openerp.addons.web import http
from openerp.addons.web.http import request
from datetime import datetime

class google_map(http.Controller):

    @http.route(['/google_map'], type='http', auth="public", website=True)
    def google_map(self, *arg, **post):
        values = {
            'partner_ids': post.get('partner_ids', ""),
            'width': post.get('width', 900),
            'height': post.get('height', 460),
            'partner_url': post.get('partner_url'),
        }
        return request.website.render("website_google_map.google_map", values)

    @http.route(['/google_map/partners.json'], type='http', auth="public", website=True)
    def google_map_data(self, *arg, **post):
        partner_obj = request.registry['res.partner']

        domain = [("id", "in", [int(p) for p in post.get('partner_ids', "").split(",") if p])]
        domain_public = domain + [('website_published', '=', True)]
        partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID,
                                         domain_public, context=request.context)
        return partner_obj.google_map_json(request.cr, openerp.SUPERUSER_ID,
                                           partner_ids, request.context)

    @http.route(['/google_map/set_partner_position'], type='http', auth="public", website=True)
    def google_map_set_partner_position(self, *arg, **post):
        partner_obj = request.registry['res.partner']

        partner_id = post.get('partner_id') and int(post['partner_id'])
        latitude = post.get('latitude') and float(post['latitude'])
        longitude = post.get('longitude') and float(post['longitude'])

        values = {
            'partner_latitude': latitude,
            'partner_longitude': longitude,
            'date_localization': datetime.now().strftime('%Y-%m-%d'),
        }
        partner_obj.write(request.cr, openerp.SUPERUSER_ID, [partner_id], values,
                          request.context)


# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:<commit_msg>[FIX] google maps controller should be for POST only<commit_after># -*- coding: utf-8 -*-

import openerp
from openerp.addons.web import http
from openerp.addons.web.http import request
from datetime import datetime

class google_map(http.Controller):

    @http.route(['/google_map'], type='http', auth="public", website=True)
    def google_map(self, *arg, **post):
        values = {
            'partner_ids': post.get('partner_ids', ""),
            'width': post.get('width', 900),
            'height': post.get('height', 460),
            'partner_url': post.get('partner_url'),
        }
        return request.website.render("website_google_map.google_map", values)

    @http.route(['/google_map/partners.json'], type='http', auth="public", website=True)
    def google_map_data(self, *arg, **post):
        partner_obj = request.registry['res.partner']

        domain = [("id", "in", [int(p) for p in post.get('partner_ids', "").split(",") if p])]
        domain_public = domain + [('website_published', '=', True)]
        partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID,
                                         domain_public, context=request.context)
        return partner_obj.google_map_json(request.cr, openerp.SUPERUSER_ID,
                                           partner_ids, request.context)

    @http.route(['/google_map/set_partner_position'], type='http', methods=['POST'], auth="public", website=True)
    def google_map_set_partner_position(self, *arg, **post):
        partner_obj = request.registry['res.partner']

        partner_id = post.get('partner_id') and int(post['partner_id'])
        latitude = post.get('latitude') and float(post['latitude'])
        longitude = post.get('longitude') and float(post['longitude'])

        values = {
            'partner_latitude': latitude,
            'partner_longitude': longitude,
            'date_localization': datetime.now().strftime('%Y-%m-%d'),
        }
        partner_obj.write(request.cr, openerp.SUPERUSER_ID, [partner_id], values,
                          request.context)


# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
{'fraction_non_alphanumeric': 0.15228186332466304, 'fraction_numerical': 0.004729250413809411, 'mean_word_length': 2.953271028037383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '968391', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1276, 'n_words': 230}