def inviteusers_POST(self,id=0): """ admin is sending out a number of invites to users """ raise Exception("not implemented") if 'emails' in self.request.arguments: emails = self.get_argument("emails") delay = 4 from demisauce.lib import scheduler for email in emails.split(','): email = email.strip().lower() user = Person.by_email(self.user.site_id,email) if user is None: user = Person(site_id=c.site_id,email=email, displayname=email) user.save() #send emails url2 = urllib.quote_plus('/user/viewh/%s' % (user.hashedemail)) dnew = {} dnew['link'] = '%s/user/verify?unique=%s&node=%s&return_url=%s' %\ (base_url(),user.user_uniqueid,user.id,url2) dnew['from'] = self.user.displayname a = Activity(site_id=user.site_id,person_id=user.id,activity='sending email invite') a.ip = self.request.remote_ip a.ref_url = 'account admin invite' a.category = 'account' a.save() scheduler.add_interval_task(send_emails,0,('invitation_to_demisauce',[user.email],dnew) , initialdelay=delay) delay += 3 return 'from form %s' % emails return 'error'
def action_get_object(self,id, data_dict = {}): if isinstance(self.id,int) and self.id > 0: #meta.DBSession.close() #meta.DBSession() self.object = Person.get(self.site.id,self.id) if not self.object: # ?? self.object = Person.by_foreignid(self.site.id,self.id) elif isinstance(self.id,int) and self.id == 0 and 'email' in data_dict: self.object = Person.by_email(self.site.id,data_dict['email'].lower()) elif 'foreign_id' in data_dict: self.object = Person.by_foreignid(self.site.id,data_dict['foreign_id']) else: id = urllib.unquote_plus(self.id) if mailsrch.match(id): self.object = Person.by_email(self.site.id,id) else: self.object = Person.by_hashedemail(self.site.id,id) log.debug('getting by hashed/email: %s, %s' % (id, self.object)) if self.object: self.qry = [self.object]