[REF] Refactoring according to the first review of CHS

bzr revid: jke@openerp.com-20140110170912-im9p7j5wf229k4d6
This commit is contained in:
jke-openerp 2014-01-10 18:09:12 +01:00
parent ecca2f99c3
commit 656f8241d5
13 changed files with 588 additions and 624 deletions

View File

@ -19,5 +19,6 @@
#
##############################################################################
import calendar
import models
import controllers
import contacts

View File

@ -43,6 +43,7 @@ If you need to manage your meetings, you should install the CRM module.
'security/calendar_security.xml',
'security/ir.model.access.csv',
'calendar_view.xml',
'contacts_view.xml',
'calendar_data.xml',
],
'js': [

View File

@ -118,7 +118,7 @@
<field name="object">crm.meeting</field>
</record>
<record id="crm_email_template_meeting_invitation" model="email.template">
<record id="calendar_template_meeting_invitation" model="email.template">
<field name="name">Meeting Invitation</field>
<field name="email_from">${object.event_id.user_id.email or ''}</field>
<field name="subject">${object.event_id.name}</field>
@ -241,7 +241,7 @@
</field>
</record>
<record id="crm_email_template_meeting_changedate" model="email.template">
<record id="calendar_template_meeting_changedate" model="email.template">
<field name="name">Meeting Invitation</field>
<field name="email_from">${object.event_id.user_id.email or ''}</field>
<field name="subject">${object.event_id.name} - Date has been updated</field>
@ -366,7 +366,7 @@
</field>
</record>
<record id="crm_email_template_meeting_reminder" model="email.template">
<record id="calendar_template_meeting_reminder" model="email.template">
<field name="name">Meeting Invitation</field>
<field name="email_from">${object.event_id.user_id.email or ''}</field>
<field name="subject">${object.event_id.name} - Reminder</field>

View File

@ -7,10 +7,10 @@
<!--For Meetings -->
<record id="res_partner_another" model="res.partner">
<field name="name">Another Partner</field>
<field name="name">Arshaw</field>
<field name="company_id" ref="base.main_company"/>
<field name="customer" eval="False"/>
<field name="email">another_partner@example.com</field>
<field name="email">fullcalendar@example.com</field>
</record>
<record id="res_user_another" model="res.users">
<field name="name" >Second Demo User</field>
@ -19,12 +19,12 @@
<field name="company_id" ref="base.main_company" />
</record>
<record id="cal_contact_1" model="web_calendar.contacts">
<record id="cal_contact_1" model="calendar.contacts">
<field eval="1" name="active"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_1"/>
</record>
<record id="cal_contact_2" model="web_calendar.contacts">
<record id="cal_contact_2" model="calendar.contacts">
<field eval="1" name="active"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.partner_demo"/>
@ -107,7 +107,7 @@
<field eval="1" name="active"/>
<field name="user_id" ref="res_user_another"/>
<field name="partner_ids" eval="[(6,0,[ref('res_partner_another'),ref('base.res_partner_8')])]"/>
<field name="name">Meeting between 2 others users than me</field>
<field name="name">Presentation of the new Calendar</field>
<field name="categ_ids" eval="[(6,0,[ref('categ_meet1'), ref('categ_meet2')])]"/>
<field eval="time.strftime('%Y-%m-16 6:00:00')" name="date"/>
<field eval="time.strftime('%Y-%m-16 18:30:00')" name="date_deadline"/>
@ -119,7 +119,7 @@
<field eval="1" name="active"/>
<field name="user_id" ref="res_user_another"/>
<field name="partner_ids" eval="[(6,0,[ref('res_partner_another'),ref('base.partner_root')])]"/>
<field name="name">Meeting between 2 others users than me</field>
<field name="name">Discuss about the module : Calendar </field>
<field name="categ_ids" eval="[(6,0,[ref('categ_meet1'), ref('categ_meet2')])]"/>
<field eval="time.strftime('%Y-%m-16 6:00:00')" name="date"/>
<field eval="time.strftime('%Y-%m-16 18:30:00')" name="date_deadline"/>

View File

@ -216,7 +216,7 @@
<field name="arch" type="xml">
<calendar string="Meetings" date_start="date" date_stop="date_deadline" date_delay="duration" all_day="allday"
display="[name]" color="color_partner_id" attendee="partner_ids" avatar_model="res.partner"
use_contacts="True" quick_add="True" event_open_popup="%(calendar.view_crm_meeting_form_popup)s">
use_contacts="True" event_open_popup="%(calendar.view_crm_meeting_form_popup)s">
<field name="name"/>
<field name="user_id"/>

View File

@ -0,0 +1,14 @@
from openerp.osv import fields, osv
class calendar_contacts(osv.osv):
_name = 'calendar.contacts'
_columns = {
'user_id': fields.many2one('res.users','Me'),
'partner_id': fields.many2one('res.partner','Employee',required=True, domain=[('customer','=',True)]),
'active':fields.boolean('active'),
}
_defaults = {
'user_id': lambda self, cr, uid, ctx: uid,
'active' : True,
}

View File

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="view_calendar_contacts" model="ir.ui.view">
<field name="name">My Coworkers</field>
<field name="model">calendar.contacts</field>
<field name="arch" type="xml">
<tree string="contacts" editable="bottom">
<field name="partner_id"/>
</tree>
</field>
</record>
<record id="action_calendar_contacts" model="ir.actions.act_window">
<field name="name">Calendar Contacts</field>
<field name="res_model">calendar.contacts</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_calendar_contacts" />
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click on "<b>create</b>" to select colleagues you want to see meetings.
</p><p>
Your colleagues will appear in the right list to see them in the calendar view. You will easily manage collaboration and meeting with them.
</p>
</field>
</record>
</data>
</openerp>

View File

@ -17,14 +17,13 @@ class meeting_invitation(http.Controller):
with registry.cursor() as cr:
attendee_id = attendee_pool.search(cr, openerp.SUPERUSER_ID, [('access_token','=',token)])
if not attendee_id:
# if token is not match
error_message = """Invalid Invitation Token."""
# elif request.session.uid and request.session.login != 'anonymous':
# # if valid session but user is not match
# attendee = attendee_pool.browse(cr, openerp.SUPERUSER_ID, attendee_id[0])
# user = registry.get('res.users').browse(cr, openerp.SUPERUSER_ID, request.session.uid)
# if attendee.partner_id.user_id.id != user.id:
# error_message = """Invitation cannot be forwarded via email. This event/meeting belongs to %s and you are logged in as %s. Please ask organizer to add you.""" % (attendee.email, user.email)
elif request.session.uid and request.session.login != 'anonymous':
# if valid session but user is not match
attendee = attendee_pool.browse(cr, openerp.SUPERUSER_ID, attendee_id[0])
user = registry.get('res.users').browse(cr, openerp.SUPERUSER_ID, request.session.uid)
if attendee.partner_id.user_id.id != user.id:
error_message = """Invitation cannot be forwarded via email. This event/meeting belongs to %s and you are logged in as %s. Please ask organizer to add you.""" % (attendee.email, user.email)
if error_message:
raise BadRequest(error_message)
@ -75,16 +74,21 @@ class meeting_invitation(http.Controller):
}
# Function used, in RPC to check every 5 minutes, if notification to do for an event or not
@http.route('/calendar/NextNotify', type='json', auth="none")
def NextNotify(self, type=''):
@http.route('/calendar/notify', type='json', auth="none")
def notify(self):
registry = openerp.modules.registry.RegistryManager.get(request.session.db)
uid = request.session.uid
context = request.session.context
with registry.cursor() as cr:
if type=='GET':
res = registry.get("calendar.alarm_manager").get_next_event(cr,uid,context=context)
return res
elif type=="UPDATE":
res = registry.get("res.partner").update_cal_last_event(cr,uid,context=context)
return res
res = registry.get("calendar.alarm_manager").do_run_next_event(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").update_cal_last_event(cr,uid,context=context)
return res

File diff suppressed because it is too large Load Diff

View File

@ -12,3 +12,5 @@ access_crm_meeting_type_sale_user,crm.meeting.type.user,model_crm_meeting_type,b
access_crm_meeting_type_sale_user,crm.meeting.type.salesman,model_crm_meeting_type,base.group_sale_salesman,1,0,0,0
access_crm_meeting_type_manager,crm.meeting.type.manager,model_crm_meeting_type,base.group_system,1,1,1,1
access_calendar_alarm_manager,access_calendar_alarm_manager,model_calendar_alarm_manager,,1,1,1,1
access_calendar_contacts_all,access_calendar_contacts_all,model_calendar_contacts,,1,1,1,1
access_calendar_contacts,access_calendar_contacts,model_calendar_contacts,base.group_system,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
12 access_crm_meeting_type_sale_user crm.meeting.type.salesman model_crm_meeting_type base.group_sale_salesman 1 0 0 0
13 access_crm_meeting_type_manager crm.meeting.type.manager model_crm_meeting_type base.group_system 1 1 1 1
14 access_calendar_alarm_manager access_calendar_alarm_manager model_calendar_alarm_manager 1 1 1 1
15 access_calendar_contacts_all access_calendar_contacts_all model_calendar_contacts 1 1 1 1
16 access_calendar_contacts access_calendar_contacts model_calendar_contacts base.group_system 1 1 1 1

View File

@ -5,14 +5,12 @@ openerp.calendar = function(instance) {
instance.web.WebClient = instance.web.WebClient.extend({
getMyNotifBox: function(me) {
get_notif_box: function(me) {
return $(me).closest(".ui-notify-message-style");
},
get_next_event: function() {
var self= this;
this.rpc("/calendar/NextNotify", {
type: "GET"
})
this.rpc("/calendar/notify")
.then(
function(result) {
console.log(result);
@ -20,35 +18,29 @@ openerp.calendar = function(instance) {
setTimeout(function() {
//If notification not already displayed, we add button and action on it
if (!($.find(".eid_"+res.event_id)).length) {
res.title = "<span class='link2event eid_" + res.event_id + "'>" + res.title + "</span>";
res.message += "<br/><br/><button class='link2showed oe_highlight oe_form oe_button'><span>OK</span></button> \
<button class='link2event'>Details</button> \
<button class='link2recall ' >Snooze</button> ";
res.title = QWeb.render('notify_title', {'title': res.title, 'id' : res.event_id});
res.message += QWeb.render("notify_footer");
a = self.do_notify(res.title,res.message,true);
$(".link2event").on('click', function() {
$(".link2event").on('click', function() {
self.rpc("/web/action/load", {
action_id: "calendar.action_crm_meeting_notify",
}).then( function(r) {
r.res_id = res.event_id;
return self.action_manager.do_action(r);
});
});
});
a.element.find(".link2recall").on('click',function() {
self.getMyNotifBox(this).find('.ui-notify-close').trigger("click");
});
self.get_notif_box(this).find('.ui-notify-close').trigger("click");
});
a.element.find(".link2showed").on('click',function() {
self.getMyNotifBox(this).find('.ui-notify-close').trigger("click");
self.rpc("/calendar/NextNotify", {
type: "UPDATE"
});
self.get_notif_box(this).find('.ui-notify-close').trigger("click");
self.rpc("/calendar/notify_ack");
});
}
//If notification already displayed in the past, we remove the css attribute which hide this notification
else if (self.getMyNotifBox($.find(".eid_"+res.event_id)).attr("style") !== ""){
self.getMyNotifBox($.find(".eid_"+res.event_id)).attr("style","");
else if (self.get_notif_box($.find(".eid_"+res.event_id)).attr("style") !== ""){
self.get_notif_box($.find(".eid_"+res.event_id)).attr("style","");
}
},res.timer * 1000);
});
@ -74,7 +66,7 @@ openerp.calendar = function(instance) {
instance.calendar.invitation = instance.web.Widget.extend({
init: function(parent, db, action, id, view, attendee_data) {
this._super();
this._super(parent); // ? parent ?
this.db = db;
this.action = action;
this.id = id;
@ -112,7 +104,7 @@ openerp.calendar = function(instance) {
initialize_texttext: function() {
return _.extend(this._super(),{
html : {
tag: '<div class="text-tag"><div class="text-button"><a class="oe_invitation custom-edit"/><span class="text-label"/><a class="text-remove"/></div></div>'
tag: QWeb.render('m2mattendee_tag')
}
});
},

View File

@ -10,7 +10,27 @@
<t t-set="i" t-value="i + 1"/>
</t>
</t>
<t t-name='notify_title'>
<span t-attf-class="'link2event eid_' + id" class='link2event eid_" + res.event_id + "'>
<t t-esc="title"/>
</span>
</t>
<t t-name='notify_footer'>
<br/><br/>
<button class='link2showed oe_highlight oe_form oe_button '><span>OK</span></button>
<button class='link2event '>Details</button>
<button class='link2recall '>Snooze</button>
</t>
<t t-name='m2mattendee_tag'>
<div class="text-tag">
<div class="text-button">
<a class="oe_invitation custom-edit"/>
<span class="text-label"/>
<a class="text-remove"/>
</div>
</div>
</t>
<t t-name="invitation_view">
<div class="oe_right"><b><t t-esc="invitation['current_attendee'].cn"/> (<t t-esc="invitation['current_attendee'].email"/>)</b></div>
<div class="oe_left"><img class="cal_inline cal_image" t-attf-src="data:image/png;base64,#{invitation['logo']}"/><p class="cal_tag cal_inline">Calendar</p></div>

View File

@ -40,7 +40,7 @@ class google_calendar_controller(http.Controller):
# Checking that user have already accepted OpenERP to access his calendar !
if gc_obj.need_authorize(request.cr, request.uid,context=kw.get('LocalContext')):
url = gc_obj.authorize_google_uri(request.cr, request.uid, from_url=kw.get('fromurl'),context=kw.get('LocalContext'))
url = gc_obj.authorize_google_uri(request.cr, request.uid, from_url=kw.get('fromurl'), context=kw.get('LocalContext'))
return {
"status" : "NeedAuth",
"url" : url
@ -49,5 +49,5 @@ class google_calendar_controller(http.Controller):
# If App authorized, and user access accepted, We launch the synchronization
return gc_obj.synchronize_events(request.cr, request.uid, [], kw.get('LocalContext'))
return { "status" : "SUCCESS" }
return { "status" : "Success" }