def getVars(user, activity): var = {} var['UserName'] = user.Name var['ActivityTitle'] = 'Cita' if activity.Type == 0 and activity.ServiceId: service = Service.getRecordById(activity.ServiceId) if service and service.Name: var['ActivityTitle'] = service.Name elif activity.Type in (1, 2) and activity.Comment: var['ActivityTitle'] = activity.Comment elif activity.Type in (1, 2) and activity.ServiceId: service = Service.getRecordById(activity.ServiceId) if service and service.Name: var['ActivityTitle'] = service.Name var['ProfId'] = activity.ProfId prof = User.getRecordById(activity.ProfId) if prof and prof.Name: var['ProfId'] = prof.Name var['UserAddress'] = '' if prof and prof.Address: var['UserAddress'] = prof.Address if prof and prof.City: var['UserAddress'] += " %s" % prof.City var['UserPhone'] = '' if prof and prof.Phone: var['UserPhone'] = prof.Phone if len(activity.Schedules) > 0: row = activity.Schedules[0] transdate = strToDate(row.TransDate) datestr = "%s %i de %s de %i" % (WeekName[transdate.weekday()], transdate.day, meses[transdate.month], transdate.year) var['TransDateStr'] = datestr var['TransDate'] = transdate.strftime("%d.%m.%Y") var['StartTime'] = strToTime(row.StartTime).strftime("%H:%M") var['EndTime'] = strToTime(row.EndTime).strftime("%H:%M") company = Company.getRecordById(activity.CompanyId) var['CompanyName'] = '' if company and company.Name: var['CompanyName'] = company.Name var['WebSite'] = '' if company and company.WebSite: var['WebSite'] = company.WebSite if company and company.Address and not var['UserAddress']: var['UserAddress'] = company.Address if company.City: var['UserAddress'] += " %s" % company.City if company and company.Phone and not var['UserPhone']: var['UserPhone'] = company.Phone return var
def setMailActivity(self, user_id, type): user = User.getRecordById(user_id) if user: if type == self.ACTIVITY_UPDATE and user.NtfActivityChange: res = sendMailUpdateActivity(user, self) elif type == self.ACTIVITY_NEW and user.NtfActivityNew: res = sendMailNewActivity(user, self) elif type == self.ACTIVITY_CANCEL and user.NtfActivityCancel: res = sendMailCancelActivity(user, self) elif type == self.ACTIVITY_CONFIRM and user.NtfActivityConfirm: res = sendMailConfirmActivity(user, self) elif type == self.ACTIVITY_NEW_CUST and user.NtfActivityNewCust: res = sendMailNewCustActivity(user, self) return True
def beforeInsert(self): Record.beforeInsert(self) user = User.getRecordById(self.FavoriteId) if user and user.CompanyId: self.CompanyId = user.CompanyId