예제 #1
0
파일: control.py 프로젝트: labase/activnce
    def post(self, id_community):
        user = self.get_current_user()
        _comu = core.model.Community().retrieve(id_community)            
        
        if _comu:
            emails = self.get_argument("emails", "").lower()
            #print emails
            #re.split(',|\s', emails)
            #print emails
            email_array = list(set(emails.split()))
            
            users_list = []
            not_users_list = []
            error_list = []
            
            form_convidar = False
            form_chamar = False
                          
            if not email_array:
                self.render("modules/community/searchgroup-form.html", REGISTRY_ID=id_community, TABS=self.setTabs(_comu), \
                            NOMEPAG='participantes', MSG=u"Informe a lista de emails que deseja convidar.")  
                
            else:
                for email in email_array:
                    if not validateEmail(email):
                        error_list.append(email)
                    else:
                        member_list = usersByEmail(email)
                        if member_list:
                            for member in member_list:
                                _member = core.model.Member().retrieve(member)   
                                status = ""
                                if member in _comu.participantes:
                                    status = u"já participa desta comunidade"
                                elif member in _comu.participantes_pendentes:
                                    status = u"já foi convidado"
                                else:
                                    status = "convidar"
                                    form_convidar = True
    
                                users_list.append((member,_member.getFullName(), status, email))
                                users_list = sorted(users_list, key=itemgetter(2), reverse=True)
                        else: 
                            status = ""
                            if email in _comu.participantes_chamados:
                                status = u"já foi chamado"
                            else:
                                status = "chamar"
                                form_chamar = True
    
                            not_users_list.append((email, status))
                            not_users_list = sorted(not_users_list, key=itemgetter(1), reverse=True)

                self.render("modules/community/invitegroup-form.html", REGISTRY_ID=id_community, TABS=self.setTabs(_comu), \
                            EMAILS=emails, \
                            USERSLIST=users_list, NOTUSERSLIST=not_users_list, ERRORLIST=error_list, \
                            FORMCONVIDAR=form_convidar, FORMCHAMAR=form_chamar, \
                            NOMEPAG='participantes', MSG=u"")                            


        else:
            raise HTTPError(404)
예제 #2
0
파일: control.py 프로젝트: labase/activnce
 def _validate_emails(self, email_array):
     msg_erro = ''
     for email in email_array:
         if not validateEmail(email):
             msg_erro += u"E-mail inválido: %s<br/>"%email
     return msg_erro