[FIX] fix bug in send_mail_to_attendee of calendar where we passed browse_list and not dict(ids), typo controller calendarr PEP8
bzr revid: jke@openerp.com-20140225165859-1vyjtirgjmbhoij4
This commit is contained in:
parent
2907c8dd66
commit
8b927d7d1c
|
@ -334,22 +334,22 @@ class calendar_alarm_manager(osv.AbstractModel):
|
|||
res = {}
|
||||
base_request = """
|
||||
SELECT
|
||||
crm.id,
|
||||
crm.date - interval '1' minute * calcul_delta.max_delta AS first_alarm,
|
||||
cal.id,
|
||||
cal.date - interval '1' minute * calcul_delta.max_delta AS first_alarm,
|
||||
CASE
|
||||
WHEN crm.recurrency THEN crm.end_date - interval '1' minute * calcul_delta.min_delta
|
||||
ELSE crm.date_deadline - interval '1' minute * calcul_delta.min_delta
|
||||
WHEN cal.recurrency THEN cal.end_date - interval '1' minute * calcul_delta.min_delta
|
||||
ELSE cal.date_deadline - interval '1' minute * calcul_delta.min_delta
|
||||
END as last_alarm,
|
||||
crm.date as first_event_date,
|
||||
cal.date as first_event_date,
|
||||
CASE
|
||||
WHEN crm.recurrency THEN crm.end_date
|
||||
ELSE crm.date_deadline
|
||||
WHEN cal.recurrency THEN cal.end_date
|
||||
ELSE cal.date_deadline
|
||||
END as last_event_date,
|
||||
calcul_delta.min_delta,
|
||||
calcul_delta.max_delta,
|
||||
crm.rrule AS rule
|
||||
cal.rrule AS rule
|
||||
FROM
|
||||
calendar_event AS crm
|
||||
calendar_event AS cal
|
||||
RIGHT JOIN
|
||||
(
|
||||
SELECT
|
||||
|
@ -359,11 +359,11 @@ class calendar_alarm_manager(osv.AbstractModel):
|
|||
LEFT JOIN calendar_alarm AS alarm ON alarm.id = rel.calendar_alarm_id
|
||||
WHERE alarm.type in %s
|
||||
GROUP BY rel.calendar_event_id
|
||||
) AS calcul_delta ON calcul_delta.calendar_event_id = crm.id
|
||||
) AS calcul_delta ON calcul_delta.calendar_event_id = cal.id
|
||||
"""
|
||||
|
||||
filter_user = """
|
||||
LEFT JOIN calendar_event_res_partner_rel AS part_rel ON part_rel.calendar_event_id = crm.id
|
||||
LEFT JOIN calendar_event_res_partner_rel AS part_rel ON part_rel.calendar_event_id = cal.id
|
||||
AND part_rel.res_partner_id = %s
|
||||
"""
|
||||
|
||||
|
@ -384,19 +384,14 @@ class calendar_alarm_manager(osv.AbstractModel):
|
|||
#Add filter on hours
|
||||
tuple_params += (seconds, seconds,)
|
||||
|
||||
cr.execute("""
|
||||
SELECT
|
||||
*
|
||||
FROM (
|
||||
%s
|
||||
) AS ALL_EVENTS
|
||||
WHERE
|
||||
ALL_EVENTS.first_alarm < (now() at time zone 'utc' + interval '%s' second )
|
||||
AND ALL_EVENTS.last_alarm > (now() at time zone 'utc' - interval '%s' second )
|
||||
""" % base_request, tuple_params)
|
||||
cr.execute("""SELECT *
|
||||
FROM ( %s ) AS ALL_EVENTS
|
||||
WHERE ALL_EVENTS.first_alarm < (now() at time zone 'utc' + interval '%%s' second )
|
||||
AND ALL_EVENTS.last_alarm > (now() at time zone 'utc' - interval '%%s' second )
|
||||
""" % base_request, tuple_params)
|
||||
|
||||
for event_id, first_alarm, last_alarm, first_meeting, last_meeting, min_duration, max_duration, rule in cr.fetchall():
|
||||
res[event_id].update({
|
||||
res[event_id] = {
|
||||
'event_id': event_id,
|
||||
'first_alarm': first_alarm,
|
||||
'last_alarm': last_alarm,
|
||||
|
@ -405,7 +400,7 @@ class calendar_alarm_manager(osv.AbstractModel):
|
|||
'min_duration': min_duration,
|
||||
'max_duration': max_duration,
|
||||
'rrule': rule
|
||||
})
|
||||
}
|
||||
|
||||
return res
|
||||
|
||||
|
@ -496,7 +491,7 @@ class calendar_alarm_manager(osv.AbstractModel):
|
|||
LastFound = False
|
||||
for one_date in self.pool.get("calendar.event").get_recurrent_date_by_event(cr, uid, curEvent, context=context):
|
||||
in_date_format = datetime.strptime(one_date, '%Y-%m-%d %H:%M:%S')
|
||||
LastFound = self.do_check_alarm_for_one_date(cr, uid, in_date_format, curEvent, max_delta, ajax_check_every_seconds, after=partner.cal_last_notif, mail=False, context=context)
|
||||
LastFound = self.do_check_alarm_for_one_date(cr, uid, in_date_format, curEvent, max_delta, ajax_check_every_seconds, after=partner.calendar_last_notif_ack, mail=False, context=context)
|
||||
if LastFound:
|
||||
for alert in LastFound:
|
||||
all_notif.append(self.do_notif_reminder(cr, uid, alert, context=context))
|
||||
|
@ -506,7 +501,7 @@ class calendar_alarm_manager(osv.AbstractModel):
|
|||
break
|
||||
else:
|
||||
in_date_format = datetime.strptime(curEvent.date, '%Y-%m-%d %H:%M:%S')
|
||||
LastFound = self.do_check_alarm_for_one_date(cr, uid, in_date_format, curEvent, max_delta, ajax_check_every_seconds, partner.cal_last_notif, mail=False, context=context)
|
||||
LastFound = self.do_check_alarm_for_one_date(cr, uid, in_date_format, curEvent, max_delta, ajax_check_every_seconds, partner.calendar_last_notif_ack, mail=False, context=context)
|
||||
if LastFound:
|
||||
for alert in LastFound:
|
||||
all_notif.append(self.do_notif_reminder(cr, uid, alert, context=context))
|
||||
|
@ -521,7 +516,7 @@ class calendar_alarm_manager(osv.AbstractModel):
|
|||
alarm = self.pool['calendar.alarm'].browse(cr, uid, alert['alarm_id'], context=context)
|
||||
|
||||
if alarm.type == 'email':
|
||||
res = self.pool['calendar.attendee']._send_mail_to_attendees(cr, uid, event.attendee_ids, template_xmlid='calendar_template_meeting_reminder', context=context)
|
||||
res = self.pool['calendar.attendee']._send_mail_to_attendees(cr, uid, [att.id for att in event.attendee_ids], template_xmlid='calendar_template_meeting_reminder', context=context)
|
||||
|
||||
return res
|
||||
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
import simplejson
|
||||
import urllib
|
||||
import openerp
|
||||
import openerp.addons.web.http as http
|
||||
from openerp.addons.web.http import request
|
||||
import openerp.addons.web.controllers.main as webmain
|
||||
import json
|
||||
from openerp.addons.web.http import SessionExpiredException
|
||||
from werkzeug.exceptions import BadRequest
|
||||
|
||||
|
||||
class meeting_invitation(http.Controller):
|
||||
|
||||
@http.route('/calendar/meeting/accept', type='http', auth="calendar")
|
||||
def accept(self, db, token, action, id,**kwargs):
|
||||
def accept(self, db, token, action, id, **kwargs):
|
||||
registry = openerp.modules.registry.RegistryManager.get(db)
|
||||
attendee_pool = registry.get('calendar.attendee')
|
||||
with registry.cursor() as cr:
|
||||
attendee_id = attendee_pool.search(cr, openerp.SUPERUSER_ID, [('access_token','=',token),('state','!=', 'accepted')])
|
||||
attendee_id = attendee_pool.search(cr, openerp.SUPERUSER_ID, [('access_token', '=', token), ('state', '!=', 'accepted')])
|
||||
if attendee_id:
|
||||
attendee_pool.do_accept(cr, openerp.SUPERUSER_ID, attendee_id)
|
||||
return self.view(db, token, action, id, view='form')
|
||||
|
@ -25,7 +23,7 @@ class meeting_invitation(http.Controller):
|
|||
registry = openerp.modules.registry.RegistryManager.get(db)
|
||||
attendee_pool = registry.get('calendar.attendee')
|
||||
with registry.cursor() as cr:
|
||||
attendee_id = attendee_pool.search(cr, openerp.SUPERUSER_ID, [('access_token','=',token),('state','!=', 'declined')])
|
||||
attendee_id = attendee_pool.search(cr, openerp.SUPERUSER_ID, [('access_token', '=', token), ('state', '!=', 'declined')])
|
||||
if attendee_id:
|
||||
attendee_pool.do_decline(cr, openerp.SUPERUSER_ID, attendee_id)
|
||||
return self.view(db, token, action, id, view='form')
|
||||
|
@ -36,13 +34,13 @@ class meeting_invitation(http.Controller):
|
|||
meeting_pool = registry.get('calendar.event')
|
||||
attendee_pool = registry.get('calendar.attendee')
|
||||
with registry.cursor() as cr:
|
||||
attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id);
|
||||
attendee = attendee_pool.search_read(cr, openerp.SUPERUSER_ID, [('access_token','=',token)],[])
|
||||
|
||||
attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id)
|
||||
attendee = attendee_pool.search_read(cr, openerp.SUPERUSER_ID, [('access_token', '=', token)], [])
|
||||
|
||||
if attendee:
|
||||
attendee_data['current_attendee'] = attendee[0]
|
||||
js = "\n ".join('<script type="text/javascript" src="%s"></script>' % i for i in webmain.manifest_list('js', db=db))
|
||||
css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in webmain.manifest_list('css',db=db))
|
||||
css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in webmain.manifest_list('css', db=db))
|
||||
|
||||
return webmain.html_template % {
|
||||
'js': js,
|
||||
|
@ -50,7 +48,7 @@ class meeting_invitation(http.Controller):
|
|||
'modules': simplejson.dumps(webmain.module_boot(db)),
|
||||
'init': "s.calendar.event('%s', '%s', '%s', '%s' , '%s');" % (db, action, id, 'form', json.dumps(attendee_data)),
|
||||
}
|
||||
|
||||
|
||||
# Function used, in RPC to check every 5 minutes, if notification to do for an event or not
|
||||
@http.route('/calendar/notify', type='json', auth="none")
|
||||
def notify(self):
|
||||
|
@ -58,15 +56,14 @@ class meeting_invitation(http.Controller):
|
|||
uid = request.session.uid
|
||||
context = request.session.context
|
||||
with registry.cursor() as cr:
|
||||
res = registry.get("calendar.alarm_manager").get_next_notif(cr,uid,context=context)
|
||||
res = registry.get("calendar.alarm_manager").get_next_notif(cr, uid, context=context)
|
||||
return res
|
||||
|
||||
|
||||
@http.route('/calendar/notify_ack', type='json', auth="none")
|
||||
def notify_ack(self, type=''):
|
||||
registry = openerp.modules.registry.RegistryManager.get(request.session.db)
|
||||
uid = request.session.uid
|
||||
context = request.session.context
|
||||
with registry.cursor() as cr:
|
||||
res = registry.get("res.partner").calendar_last_notif(cr,uid,context=context)
|
||||
res = registry.get("res.partner").calendar_last_notif_ack(cr, uid, context=context)
|
||||
return res
|
||||
|
||||
|
|
Loading…
Reference in New Issue