misc: remove unused account moderation code (#47308)
This commit is contained in:
parent
1c0b30004d
commit
f8eead3dc2
|
@ -159,14 +159,11 @@ class TokenDirectory(Directory):
|
|||
account.awaiting_confirmation = False
|
||||
account.store()
|
||||
|
||||
if account.awaiting_moderation:
|
||||
r += TextsDirectory.get_html_text('account-created-waiting-activation')
|
||||
else:
|
||||
r += TextsDirectory.get_html_text('account-created')
|
||||
passwords_cfg = get_cfg('passwords', {})
|
||||
if passwords_cfg.get('can_change', False):
|
||||
# TODO: offer a chance to change password ?
|
||||
pass
|
||||
r += TextsDirectory.get_html_text('account-created')
|
||||
passwords_cfg = get_cfg('passwords', {})
|
||||
if passwords_cfg.get('can_change', False):
|
||||
# TODO: offer a chance to change password ?
|
||||
pass
|
||||
|
||||
identities_cfg = get_cfg('identities', {})
|
||||
if identities_cfg.get('notify-on-register', False):
|
||||
|
@ -225,7 +222,7 @@ class MethodDirectory(Directory):
|
|||
r += form.render()
|
||||
r += htmltext('</div>')
|
||||
|
||||
if identities_cfg.get('creation') in ('self', 'moderated'):
|
||||
if identities_cfg.get('creation') == 'self':
|
||||
r += htmltext('<div id="register">')
|
||||
ident_methods = get_cfg('identification', {}).get('methods', [])
|
||||
if len(ident_methods) > 1:
|
||||
|
@ -264,11 +261,6 @@ class MethodDirectory(Directory):
|
|||
|
||||
def login_submit_account_user(self, account, user, form=None):
|
||||
|
||||
if account.awaiting_moderation:
|
||||
if form:
|
||||
form.set_error('username', _('This account is waiting for moderation'))
|
||||
return
|
||||
|
||||
if account.awaiting_confirmation:
|
||||
if form:
|
||||
form.set_error('username', _('This account is waiting for confirmation'))
|
||||
|
@ -582,8 +574,6 @@ class MethodDirectory(Directory):
|
|||
if password:
|
||||
account.set_password(password)
|
||||
account.user_id = user.id
|
||||
if identities_cfg.get('creation') == 'moderated':
|
||||
account.awaiting_moderation = True
|
||||
|
||||
if identities_cfg.get('email-confirmation', False):
|
||||
if not user.email:
|
||||
|
@ -599,9 +589,6 @@ class MethodDirectory(Directory):
|
|||
if identities_cfg.get('notify-on-register', False):
|
||||
notify_admins_user_registered(account)
|
||||
|
||||
if account.awaiting_moderation:
|
||||
return self.moderation_notification()
|
||||
|
||||
if passwords_cfg.get('generate', True):
|
||||
if not user.email:
|
||||
get_logger().error(
|
||||
|
@ -621,26 +608,6 @@ class MethodDirectory(Directory):
|
|||
# XXX: display a message instead of immediate redirect ?
|
||||
return redirect(get_publisher().get_root_url() + 'login/')
|
||||
|
||||
def moderation_notification(self):
|
||||
template.html_top(_('Account created, waiting for moderation'))
|
||||
r = TemplateIO(html=True)
|
||||
|
||||
r += htmltext('<div class="ident-content">')
|
||||
r += htmltext('<p>')
|
||||
r += _('A site administrator will now review then activate your account.')
|
||||
r += htmltext('</p>')
|
||||
|
||||
r += htmltext('<p>')
|
||||
r += _('You will then get your password by email.')
|
||||
r += htmltext('</p>')
|
||||
|
||||
r += htmltext('<p>')
|
||||
r += htmltext('<a href="%s">%s</a>') % (get_publisher().get_root_url(), _('Back to home page'))
|
||||
r += htmltext('</p>')
|
||||
r += htmltext('</div>')
|
||||
|
||||
return r.getvalue()
|
||||
|
||||
def confirmation_notification(self, account, user, password):
|
||||
self.email_confirmation_notification(account, user, password)
|
||||
|
||||
|
@ -767,7 +734,7 @@ class MethodAdminDirectory(Directory):
|
|||
value = identities_cfg.get('creation', 'admin'),
|
||||
options = [(str('admin'), _('Site Administrator')),
|
||||
(str('self'), _('Self-registration')),
|
||||
(str('moderated'), _('Moderated user registration'))])
|
||||
])
|
||||
form.add(CheckboxWidget, 'email-confirmation',
|
||||
title = _('Require email confirmation for new accounts'),
|
||||
value = identities_cfg.get('email-confirmation', False))
|
||||
|
@ -1042,8 +1009,6 @@ class UsernamePasswordWidget(CompositeWidget):
|
|||
autocomplete = 'off')
|
||||
self.add(CheckboxWidget, 'awaiting_confirmation', value.get('awaiting_confirmation'),
|
||||
title = _('Awaiting Confirmation'), required = False)
|
||||
self.add(CheckboxWidget, 'awaiting_moderation', value.get('awaiting_moderation'),
|
||||
title = _('Awaiting Moderation'), required = False)
|
||||
self.add(CheckboxWidget, 'disabled', value.get('disabled'),
|
||||
title = _('Disabled Account'), required = False)
|
||||
|
||||
|
@ -1051,7 +1016,6 @@ class UsernamePasswordWidget(CompositeWidget):
|
|||
value = {
|
||||
'username': self.get('username'),
|
||||
'password': self.get('password'),
|
||||
'awaiting_moderation': self.get('awaiting_moderation'),
|
||||
'awaiting_confirmation': self.get('awaiting_confirmation'),
|
||||
'disabled': self.get('disabled'),
|
||||
}
|
||||
|
@ -1151,7 +1115,6 @@ class PasswordAuthMethod(AuthMethod):
|
|||
account.hashing_algo = passwords_cfg.get('hashing_algo')
|
||||
account.set_password(value.get('password'))
|
||||
account.awaiting_confirmation = value.get('awaiting_confirmation')
|
||||
account.awaiting_moderation = value.get('awaiting_moderation')
|
||||
account.disabled = value.get('disabled')
|
||||
account.user_id = user.id
|
||||
try:
|
||||
|
@ -1178,31 +1141,10 @@ class PasswordAuthMethod(AuthMethod):
|
|||
except KeyError:
|
||||
return None
|
||||
return {'username': account.id, 'password': account.password,
|
||||
'awaiting_moderation': account.awaiting_moderation,
|
||||
'awaiting_confirmation': account.awaiting_confirmation,
|
||||
'disabled': account.disabled,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
rdb = get_publisher_class().backoffice_directory_class
|
||||
if rdb:
|
||||
rdb.register_directory('accounts', AccountsDirectory())
|
||||
|
||||
def menu_entry_check_display(k):
|
||||
identities_cfg = get_cfg('identities', {})
|
||||
if identities_cfg.get('creation') != 'moderated':
|
||||
return False
|
||||
user = get_request().user
|
||||
if not user:
|
||||
return False
|
||||
if not user.is_admin:
|
||||
return False
|
||||
return True
|
||||
|
||||
rdb.register_menu_item('accounts/', _('Accounts'),
|
||||
check_display_function=menu_entry_check_display)
|
||||
|
||||
|
||||
class AccountDirectory(Directory):
|
||||
_q_exports = ['', 'accept', 'reject', 'email']
|
||||
|
@ -1267,7 +1209,6 @@ class AccountDirectory(Directory):
|
|||
else:
|
||||
password = self.account.password
|
||||
|
||||
self.account.awaiting_moderation = False
|
||||
self.account.store()
|
||||
|
||||
try:
|
||||
|
@ -1342,63 +1283,6 @@ class AccountDirectory(Directory):
|
|||
|
||||
|
||||
|
||||
class AccountsDirectory(AccessControlled, Directory):
|
||||
_q_exports = ['']
|
||||
|
||||
def _q_access(self):
|
||||
user = get_request().user
|
||||
if not user:
|
||||
raise errors.AccessUnauthorizedError()
|
||||
if not user.is_admin:
|
||||
raise errors.AccessForbiddenError(
|
||||
public_msg = _('You are not allowed to access Accounts Management'),
|
||||
location_hint = 'backoffice')
|
||||
|
||||
get_response().breadcrumb.append(('accounts/', _('Accounts Management')))
|
||||
|
||||
def _q_index(self):
|
||||
html_top('accounts', _('Accounts Management'))
|
||||
r = TemplateIO(html=True)
|
||||
r += htmltext('<h2>%s</h2>') % _('New accounts waiting for moderation')
|
||||
|
||||
r += htmltext('<ul class="biglist">')
|
||||
for account in PasswordAccount.select(order_by = 'id'):
|
||||
if account.awaiting_confirmation:
|
||||
continue
|
||||
if not account.awaiting_moderation:
|
||||
continue
|
||||
if not account.user:
|
||||
# user has been removed; this is so wrong we remove account now
|
||||
account.remove_self()
|
||||
continue
|
||||
r += htmltext('<li>')
|
||||
r += htmltext('<strong class="label">%s</strong>') % account.user.display_name
|
||||
r += htmltext('<p class="details">')
|
||||
r += _('Username:')
|
||||
r += ' '
|
||||
r += account.id
|
||||
r += htmltext('</p>')
|
||||
|
||||
r += htmltext('<p class="commands">')
|
||||
r += command_icon('%s/' % account.id, 'view')
|
||||
if account.user.email:
|
||||
r += command_icon('%s/email' % account.id, 'email', label = _('Reply by email'))
|
||||
r += command_icon('%s/accept' % account.id, 'accept',
|
||||
label = _('Accept'), icon = 'stock_yes_16.png')
|
||||
r += command_icon('%s/reject' % account.id, 'reject',
|
||||
label = _('Reject'), icon = 'stock_no_16.png', popup = True)
|
||||
r += htmltext('</p>')
|
||||
r += htmltext('</li>')
|
||||
r += htmltext('</ul>')
|
||||
return r.getvalue()
|
||||
|
||||
def _q_lookup(self, component):
|
||||
try:
|
||||
account = PasswordAccount.get(component)
|
||||
except KeyError:
|
||||
return None
|
||||
return AccountDirectory(account)
|
||||
|
||||
EmailsDirectory.register('password-subscription-notification',
|
||||
N_('Subscription notification for password account'),
|
||||
N_('Available variables: email, website, token_url, token, admin_email, username, password'),
|
||||
|
@ -1536,15 +1420,6 @@ Here is your password for [hostname]: [password]
|
|||
'''))
|
||||
|
||||
|
||||
TextsDirectory.register('account-created-waiting-activation',
|
||||
N_('Text when account confirmed by user but waiting moderator approval'),
|
||||
category = N_('Identification'),
|
||||
default = N_('''<p>
|
||||
Your account has been created. In order to be effective
|
||||
it must be activated by a moderator. You will receive an
|
||||
email when this is done.
|
||||
</p>'''))
|
||||
|
||||
TextsDirectory.register('account-created',
|
||||
N_('Text when account confirmed by user'),
|
||||
category = N_('Identification'),
|
||||
|
|
|
@ -42,7 +42,6 @@ class PasswordAccount(StorableObject):
|
|||
hashing_algo = 'django' # delegate
|
||||
|
||||
awaiting_confirmation = False
|
||||
awaiting_moderation = False
|
||||
disabled = False
|
||||
|
||||
warned_about_unused_account = False
|
||||
|
|
Loading…
Reference in New Issue