diff --git a/mygpo/administration/templates/admin/overview.html b/mygpo/administration/templates/admin/overview.html index 1c542533b..4fea5e4ba 100644 --- a/mygpo/administration/templates/admin/overview.html +++ b/mygpo/administration/templates/admin/overview.html @@ -20,6 +20,7 @@

{% trans "Admin Area" %}

  • {% trans "User-Agent Stats" %}
  • {% trans "General Stats" %} ({% trans "JSON" %})
  • {% trans "Activate User" %}
  • +
  • {% trans "Resend Activation Email" %}
  • {% trans "Assign Publisher Permissions" %}
  • diff --git a/mygpo/administration/templates/admin/resend-acivation.html b/mygpo/administration/templates/admin/resend-acivation.html new file mode 100644 index 000000000..054508139 --- /dev/null +++ b/mygpo/administration/templates/admin/resend-acivation.html @@ -0,0 +1,41 @@ +{% extends "base.html" %} +{% load i18n %} +{% load podcasts %} + +{% load menu %} +{% block mainmenu %}{{ "/admin/"|main_menu }}{% endblock %} +{% block sectionmenu %}{{ "/admin/"|section_menu:"Admin" }}{% endblock %} + +{% block title %}{% trans "Activate User" %}{% endblock %} + +{% block header %} +

    {% trans "Resend Activation email" %}

    +{% endblock %} + +{% block content %} +
    + {% csrf_token %} + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    +
    + +
    +
    +
    + +{% endblock %} + diff --git a/mygpo/administration/urls.py b/mygpo/administration/urls.py index 1e033b84f..36a241ac7 100644 --- a/mygpo/administration/urls.py +++ b/mygpo/administration/urls.py @@ -52,6 +52,10 @@ views.ActivateUserView.as_view(), name='admin-activate-user'), + path('resend-activation-email', + views.ResendActivationEmail.as_view(), + name='admin-resend-activation'), + path('make-publisher/input', views.MakePublisherInput.as_view(), name='admin-make-publisher-input'), diff --git a/mygpo/administration/views.py b/mygpo/administration/views.py index 16353feea..2a19d7b37 100644 --- a/mygpo/administration/views.py +++ b/mygpo/administration/views.py @@ -27,6 +27,7 @@ from mygpo.administration.group import PodcastGrouper from mygpo.maintenance.merge import PodcastMerger, IncorrectMergeException from mygpo.administration.clients import UserAgentStats, ClientStats +from mygpo.users.views.registration import send_activation_email from mygpo.administration.tasks import merge_podcasts from mygpo.utils import get_git_head from mygpo.data.models import PodcastUpdateResult @@ -330,7 +331,7 @@ def post(self, request): return HttpResponseRedirect(reverse('admin-activate-user')) try: - user = UserProxy.objects.by_username_or_email(username, email) + user = UserProxy.objects.all().by_username_or_email(username, email) except UserProxy.DoesNotExist: messages.error(request, _('No user found')) return HttpResponseRedirect(reverse('admin-activate-user')) @@ -342,6 +343,42 @@ def post(self, request): return HttpResponseRedirect(reverse('admin-activate-user')) +class ResendActivationEmail(AdminView): + """ Resends the users activation email """ + + template_name = 'admin/resend-acivation.html' + + def get(self, request): + return self.render_to_response({}) + + def post(self, request): + + username = request.POST.get('username') + email = request.POST.get('email') + + if not (username or email): + messages.error(request, + _('Provide either username or email address')) + return HttpResponseRedirect(reverse('admin-resend-activation')) + + try: + user = UserProxy.objects.all().by_username_or_email(username, email) + except UserProxy.DoesNotExist: + messages.error(request, _('No user found')) + return HttpResponseRedirect(reverse('admin-resend-activation')) + + if user.is_active: + messages.success(request, 'User {username} is already activated') + + else: + send_activation_email(user, request) + messages.success(request, + _('Email for {username} ({email}) resent'.format( + username=user.username, email=user.email))) + + return HttpResponseRedirect(reverse('admin-resend-activation')) + + class MakePublisherInput(AdminView): """ Get all information necessary for making someone publisher """