cleanup: remove account moderation views (#48589)
This commit is contained in:
parent
c9bc9f6bf0
commit
decee022ac
|
@ -927,143 +927,6 @@ class PasswordAuthMethod(AuthMethod):
|
|||
}
|
||||
|
||||
|
||||
class AccountDirectory(Directory):
|
||||
_q_exports = ['', 'accept', 'reject', 'email']
|
||||
|
||||
def __init__(self, account):
|
||||
self.account = account
|
||||
|
||||
def _q_traverse(self, path):
|
||||
get_response().breadcrumb.append(('%s/' % self.account.id, self.account.id))
|
||||
return Directory._q_traverse(self, path)
|
||||
|
||||
def _q_index(self):
|
||||
identities_cfg = get_cfg('identities', {})
|
||||
users_cfg = get_cfg('users', {})
|
||||
|
||||
html_top('accounts', _('Account - %s') % self.account.id)
|
||||
r = TemplateIO(html=True)
|
||||
r += htmltext('<h2>%s</h2>') % _('Moderation of account')
|
||||
|
||||
r += htmltext('<div class="dataview">')
|
||||
|
||||
if not identities_cfg.get('email-as-username', False):
|
||||
r += htmltext('<div class="field"><span class="label">%s</span>') % _('Username')
|
||||
r += htmltext('<span class="value">%s</span></div>') % self.account.id
|
||||
else:
|
||||
if not users_cfg.get('field_email'):
|
||||
r += htmltext('<div class="field"><span class="label">%s</span>') % _('Email')
|
||||
r += htmltext('<span class="value">%s</span></div>') % self.account.id
|
||||
|
||||
formdef = get_publisher().user_class.get_formdef()
|
||||
if formdef:
|
||||
data = self.account.user.form_data
|
||||
for f in formdef.fields:
|
||||
if f.id not in data:
|
||||
continue
|
||||
value = data[f.id]
|
||||
if value is None or value == '':
|
||||
continue
|
||||
|
||||
r += htmltext('<div class="field"><span class="label">%s</span> ') % f.label
|
||||
r += htmltext('<div class="value">')
|
||||
s = f.get_view_value(value)
|
||||
r += htmltext(s)
|
||||
r += htmltext('</div></div>')
|
||||
r += htmltext('</div>')
|
||||
|
||||
if self.account.user.email:
|
||||
r += htmltext('<a href="email">%s</a> - ') % _('Reply by email')
|
||||
r += htmltext('<a href="accept">%s</a>') % _('Accept')
|
||||
r += ' - '
|
||||
r += htmltext('<a href="reject">%s</a>') % _('Reject')
|
||||
return r.getvalue()
|
||||
|
||||
def accept(self):
|
||||
passwords_cfg = get_cfg('passwords', {})
|
||||
if passwords_cfg.get('generate', True) and self.account.hashing_algo:
|
||||
# generated password, as it may be hashed, create it now
|
||||
password = make_password()
|
||||
self.account.set_password(str(password))
|
||||
elif self.account.hashing_algo:
|
||||
password = None
|
||||
else:
|
||||
password = self.account.password
|
||||
|
||||
self.account.store()
|
||||
|
||||
try:
|
||||
user = self.account.user
|
||||
except KeyError:
|
||||
user = None
|
||||
|
||||
if not user or not user.email:
|
||||
return redirect('..')
|
||||
|
||||
data = {
|
||||
'username': self.account.id,
|
||||
}
|
||||
if password:
|
||||
data['password'] = password
|
||||
|
||||
emails.custom_template_email('new-account-approved', data, user.email)
|
||||
|
||||
return redirect('..')
|
||||
|
||||
def reject(self):
|
||||
form = Form(enctype = 'multipart/form-data')
|
||||
form.add(EmailWidget, 'to', title = _('To'), value = self.account.user.email)
|
||||
form.add(StringWidget, 'subject', title = _('Subject'))
|
||||
form.add(TextWidget, 'body', title = _('Message'), cols = 80, rows = 15)
|
||||
form.add_submit('submit', _('Submit'))
|
||||
form.add_submit('submit-no-msg', _("Submit and don't send email"))
|
||||
form.add_submit('cancel', _('Cancel'))
|
||||
|
||||
if form.get_submit() == 'cancel':
|
||||
return redirect('.')
|
||||
|
||||
if not form.is_submitted():
|
||||
get_response().breadcrumb.append(('reject', _('Rejection')))
|
||||
html_top('accounts', _('Rejection'))
|
||||
return form.render()
|
||||
else:
|
||||
self.account.user.remove_self()
|
||||
self.account.remove_self()
|
||||
if form.get_submit() != 'submit-no-msg':
|
||||
mail_subject = form.get_widget('subject').parse()
|
||||
mail_body = form.get_widget('body').parse()
|
||||
to = form.get_widget('to').parse()
|
||||
emails.email(mail_subject, mail_body, to)
|
||||
return redirect('..')
|
||||
|
||||
def email(self):
|
||||
form = Form(enctype = 'multipart/form-data')
|
||||
form.add(EmailWidget, 'to', title = _('To'), value = self.account.user.email)
|
||||
form.add(StringWidget, 'subject', title = _('Subject'), size = 35,
|
||||
value = _('About your account request'))
|
||||
form.add(TextWidget, 'body', title = _('Message'), cols = 80, rows = 15)
|
||||
form.add_submit('submit', _('Submit'))
|
||||
form.add_submit('cancel', _('Cancel'))
|
||||
|
||||
if form.get_submit() == 'cancel':
|
||||
return redirect('.')
|
||||
|
||||
if not form.is_submitted():
|
||||
get_response().breadcrumb.append(('email', _('Reply by email')))
|
||||
html_top('accounts', _('Reply by email'))
|
||||
r = TemplateIO(html=True)
|
||||
r += htmltext('<h2>%s</h2>') % _('Reply by email')
|
||||
r += form.render()
|
||||
return r.getvalue()
|
||||
else:
|
||||
mail_subject = form.get_widget('subject').parse()
|
||||
mail_body = form.get_widget('body').parse()
|
||||
to = form.get_widget('to').parse()
|
||||
emails.email(mail_subject, mail_body, to)
|
||||
return redirect('.')
|
||||
|
||||
|
||||
|
||||
EmailsDirectory.register('password-subscription-notification',
|
||||
N_('Subscription notification for password account'),
|
||||
N_('Available variables: email, website, token_url, token, admin_email, username, password'),
|
||||
|
|
Loading…
Reference in New Issue