def canceldeactive(self,*args,**kw):
     
     self.title ="test"
     self.message =  LanguageObject.getdata("msg_already_deactivate")
     
     if(len(args) >0 and args[0] != None):
         self.userGenCode =  model.UserGenCode.getByDeactivateCode(args[0]);
         if self.userGenCode:
             self.user = model.User.getId(self.userGenCode.user_id)
             self.user.active = 1
             self.userGenCode.success = 0
             
             
             self.emailValues={};
             self.emailValues['user_name'] = self.user.display_name;
             self.emailValues['email'] = self.user.email_address;
             # self.emailValues['password'] = self.password;
             
            
             self.sendMailService = SendMailService();
             self.sendMailService.sendWelcomeActivate(self.emailValues);
             self.sendMailService.start();
             
             
             self.message =LanguageObject.getdata("msg_success_deactivate")  
     else:
         self.message = LanguageObject.getdata("failed")       
             
     
     
     return dict(page='canceldeactivate', title=self.title, message=self.message)
 def value(self,*args, **kw):
     
     self.activate_code = args
     if(len(self.activate_code) > 0): 
         self.userGenCode =  model.UserGenCode.getByActivateCode(self.activate_code[0])
         self.message = "";
         
         if (self.userGenCode ):
             if ( not self.utility.convertToBool(self.userGenCode.success) ):
                 
                 if (self.utility.isActiveFromDate(self.utility.getCurrentDate() , self.userGenCode.create_date ,self.userGenCode.expire_date   ) ):
                     self.userGenCode.success = 1;
                     self.message =   LanguageObject.getdata("msg_success_activate")  
                     
                 else : 
                     self.message = LanguageObject.getdata("msg_expire_activate") 
                       
                     override_template(ActivateController.value, 'genshi:pollandsurvey.templates.register.reactivate') 
                      
             else:
                 self.message = LanguageObject.getdata("msg_already_activate")
                 
         
         else:
             self.message = LanguageObject.getdata("msg_not_found_activate")
             log.warning("Find not found activate code  %s", self.activate_code )
     else:
         #self.message = "Thank you!";
         log.warning("User income is wrong,have not activate code")
         redirect("/")
      
     
     #for key in request.environ:   print "%s --- %s"   %(  key, request.environ[key]);
      
     return dict(page='activate_success',message = self.message) 
    def rechangepass(self, *args, **kw):

        self.success = False
        self.message = ""
        if request.identity:
            self.current_password = kw.get("password")
            self.new_password = kw.get("newpassword")
            self.re_new_password = kw.get("rnewpassword")
            user = request.identity["user"]

            if user.validate_password(self.current_password):
                if str(self.new_password) == str(self.re_new_password):
                    user._set_password(self.new_password)
                    self.success = True
                    self.message = LanguageObject.getdata("msg_password_changed")
                else:
                    self.message = LanguageObject.getdata("msg_password_not_match")

            else:
                log.warning("user %s password not match : %s", user.user_name, self.current_password)
                self.message = LanguageObject.getdata("msg_password_not_match")
        else:
            self.message = LanguageObject.getdata("msg_not_login")
            log.warning("user cannot login, redirect to login")

        flash(_(self.message), "warning")
        # return dict(success=self.success, message = self.message);

        redirect("/account/changepass")
    def rechangepass(self, *args, **kw):
        self.success = False
        self.message = ''
        if request.identity:
            self.current_password = kw.get('password')
            self.new_password = kw.get('newpassword')
            self.re_new_password = kw.get('rnewpassword')

            user = request.identity['user']

            if (user.validate_password(self.current_password)):
                if (str(self.new_password) == str(self.re_new_password)):
                    user._set_password(self.new_password)
                    self.success = True
                    self.message = LanguageObject.getdata(
                        "msg_password_changed")
                else:
                    self.message = LanguageObject.getdata(
                        "msg_password_not_match")

            else:
                log.warning("user %s password not match : %s", user.user_name,
                            self.current_password)
                self.message = LanguageObject.getdata("msg_password_not_match")
        else:
            self.message = LanguageObject.getdata("msg_not_login")
            log.warning("user cannot login, redirect to login")

        flash(_(self.message), 'warning')
        redirect('/managepoll/account/changepass')
 def create(self,*args,**kw):
     
     log.info(kw);
     print kw
     print len(kw)
     if len(kw) == 0:
         redirect( '/login')
     
     try:
         self.email = kw.get('email');
         self.password = kw.get('password');
         self.rpassword = kw.get('rpassword');
         
         self.success= True;
         self.message = "create success";
         self.urlServer =  model.SystemEnvironment.getServerUrl();
         
         u = model.User.by_email_address(self.email);
         if u is None:
              
             if( str(self.password) ==  str(self.rpassword) ):
                 
                  
                 self.user,self.userGenCode = self.registerService.createUser(kw);
                 
                 self.emailValues={};
                 self.emailValues['user_name'] = self.user.display_name;
                 self.emailValues['email'] = self.user.email_address;
                 self.emailValues['password'] = self.password;
                 self.emailValues['activate_url'] =  request.scheme   + '://' + self.urlServer + "/activate/value/" + str(self.userGenCode.code);  #request.application_url
                 
                 self.sendMailService = SendMailService();
                 self.sendMailService.sendActivate(self.emailValues);
                 self.sendMailService.start();
                     
                 log.info("create user : %s " , self.email);
                 
                 
             else:
                 self.message ="password not same";
                 self.success= False;
                 log.info("password not same : %s " , self.email);
              
         else:
             self.message = "email have already";
             self.success= False;
             log.info("email have already : %s " , self.email);
         u =None;
     except Exception as inst:
         log.error("error : %s " %inst);
         flash(_(LanguageObject.getdata("msg_error_data_register")), 'warning')   
         redirect( '/login')
     return dict(success=self.success, message = self.message);
    def updateprofile(self, *args, **kw):

        if request.identity:

            self.user = request.identity["user"]
            self.userService = model.UserService.getById(self.user.user_id)
            if self.userService is None:
                self.userService = model.UserService()
            self.userService.updateByValue(**kw)
            self.userService.accept_tnc = 1
            self.userService.user_id = self.user.user_id
            self.userService.birthdate = self.utility.convertToDateTime(self.userService.birthdate, "%d/%m/%Y")
            self.userService.updateall()

            flash(_(LanguageObject.getdata("msg_save_success")), "warning")
        else:

            log.warning("user cannot login, redirect to login")
            flash(_(LanguageObject.getdata("msg_not_login")), "warning")

        redirect("/account")
Exemple #7
0
    def addContactUs(self, **kw):
        reload(sys).setdefaultencoding('utf8')
        self.userid = None
        self.ContactUs = json.loads(request.body,
                                    encoding=request.charset,
                                    object_hook=self.__toContactUs)
        log.info(request.body, extra=extraLog())

        if request.identity:
            user = request.identity['user']
            self.ContactUs.user_id = user.user_id
            self.ContactUs.reporter = user.display_name
            self.ContactUs.email = user.user_name

        self.ContactUs.save()
        return dict(status=True,
                    header="Information",
                    message=LanguageObject.getdata(
                        key="msg_save_success_contactus", code=True))
    def deactivate(self):
        self.user = request.identity["user"]
        self.user.active = 0
        # user.deactivate()

        self.urlServer = model.SystemEnvironment.getServerUrl()
        self.userGenCode = self.registerService.deActivateUserGenCode(self.user)

        self.emailValues = {}
        self.emailValues["user_name"] = self.user.display_name
        self.emailValues["email"] = self.user.email_address
        self.emailValues["deactivate_url"] = (
            request.scheme + "://" + self.urlServer + "/activate/canceldeactive/" + str(self.userGenCode.code)
        )
        # request.application_url

        self.sendMailService = SendMailService()
        self.sendMailService.senddeActivate(self.emailValues)
        self.sendMailService.start()

        # model.User.deactivate()
        flash(_(LanguageObject.getdata("msg_thank_you")), "warning")
        redirect("/logout_handler")