示例#1
0
 def accept(self):
     if not self.uw.isReadOnly():
         un = self.username
         if not un:
             return error_dialog(
                 self,
                 _('Empty username'),
                 _('You must enter a username'),
                 show=True
             )
         if un in self.user_data:
             return error_dialog(
                 self,
                 _('Username already exists'),
                 _(
                     'A user with the username {} already exists. Please choose a different username.'
                 ).format(un),
                 show=True
             )
         err = validate_username(un)
         if err:
             return error_dialog(self, _('Username is not valid'), err, show=True)
     p1, p2 = self.password, self.p2.text()
     if p1 != p2:
         return error_dialog(
             self,
             _('Password do not match'),
             _('The two passwords you entered do not match!'),
             show=True
         )
     if not p1:
         return error_dialog(
             self,
             _('Empty password'),
             _('You must enter a password for this user'),
             show=True
         )
     err = validate_password(p1)
     if err:
         return error_dialog(self, _('Invalid password'), err, show=True)
     return QDialog.accept(self)
示例#2
0
 def accept(self):
     if not self.uw.isReadOnly():
         un = self.username
         if not un:
             return error_dialog(
                 self,
                 _('Empty username'),
                 _('You must enter a username'),
                 show=True
             )
         if un in self.user_data:
             return error_dialog(
                 self,
                 _('Username already exists'),
                 _(
                     'A user with the username {} already exists. Please choose a different username.'
                 ).format(un),
                 show=True
             )
         err = validate_username(un)
         if err:
             return error_dialog(self, _('Username is not valid'), err, show=True)
     p1, p2 = self.password, self.p2.text()
     if p1 != p2:
         return error_dialog(
             self,
             _('Password do not match'),
             _('The two passwords you entered do not match!'),
             show=True
         )
     if not p1:
         return error_dialog(
             self,
             _('Empty password'),
             _('You must enter a password for this user'),
             show=True
         )
     err = validate_password(p1)
     if err:
         return error_dialog(self, _('Invalid password'), err, show=True)
     return QDialog.accept(self)