def map(self): id = self.request.matchdict.get("map_id") map = Map.get(id) if map is None: return HTTPNotFound() params = dict(map) params["is_editable"] = self.has_permission(self.request.user, map) if 'cb' in self.request.params: headers = {'Content-Type': 'text/javascript; charset=utf-8'} return Response("%s(%s);" % (self.request.params['cb'], json_dumps(params)), headers=headers) else: headers = {'Content-Type': 'application/json'} return Response(json_dumps(params), headers=headers)
def comment(self): id = self.request.matchdict.get("map_id") map = Map.get(id) if map is None: return HTTPNotFound() # read the map author's email address from LDAP author = self.get_user_info(map.user_login) comment = self.request.params.get('comment') if self.request.params.get('name') and self.request.params.get('mail'): # feedback anonymous user feedback_name = self.request.params.get('name') feedback_mail = self.request.params.get('mail') else: # feedback loggedin user user = self.get_user_info(self.request.user.username) feedback_name = user[0] feedback_mail = user[1] try: message = Message( author='*****@*****.**', to=author[1], bcc='*****@*****.**', subject=(u'comment_email_subject') % {'title': map.title + " ( http://map.geoportail.lu/?map_id="+map.uuid+" ) ", 'feedback_name': feedback_name, 'feedback_mail': feedback_mail}, plain=comment) except: traceback.print_exc(file=sys.stdout) return HTTPNotFound() message.encoding = 'utf-8' message.send() return {'success': True}