Skip to content

Commit 015d82f

Browse files
committed
requested changes
1 parent 543e3e6 commit 015d82f

File tree

6 files changed

+20
-30
lines changed

6 files changed

+20
-30
lines changed

readthedocs/projects/forms.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,8 @@ def clean_name(self):
118118
if project_exist:
119119
project = Project.objects.get(slug=potential_slug)
120120
project_url = project.get_absolute_url()
121-
if project.is_abandoned:
122-
err_msg = ('Invalid project name, a <a href="{}" style="color: red">'
123-
'project</a> already exists with that name').format(project_url)
124-
else:
125-
err_msg = 'Invalid project name, a project already exists with that name'
121+
err_msg = ('Invalid project name, a <a href="{}" style="color: red">'
122+
'project</a> already exists with that name').format(project_url)
126123
raise forms.ValidationError(mark_safe(err_msg)) # yapf: disable # noqa
127124
return name
128125

readthedocs/projects/models.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,6 @@ def is_abandoned(self):
576576
return False
577577
return True
578578

579-
@property
580-
def is_abandoned_mail_sent(self):
581-
"""Is abandoned mail sent."""
582-
return self.abandoned_mail_sent
583-
584579
@property
585580
def is_type_sphinx(self):
586581
"""Is project type Sphinx."""

readthedocs/projects/urls/private.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
private.project_manage,
3737
name='projects_manage'),
3838

39-
url(r'^(?P<project_slug>[-\w]+)/send_mail/$',
40-
private.send_mail,
41-
name='send_mail'),
39+
url(r'^(?P<project_slug>[-\w]+)/send_abandoned_mail/$',
40+
private.send_abandoned_mail,
41+
name='send_abandoned_mail'),
4242

4343
url(r'^(?P<project_slug>[-\w]+)/comments_moderation/$',
4444
private.project_comments_moderation,

readthedocs/projects/views/private.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from allauth.socialaccount.models import SocialAccount
1010
from django.contrib import messages
11-
from django.contrib.auth.decorators import login_required
11+
from django.contrib.auth.decorators import login_required, user_passes_test
1212
from django.contrib.auth.models import User
1313
from django.core.urlresolvers import reverse
1414
from django.http import (
@@ -265,23 +265,21 @@ def is_advanced(self):
265265
return data.get('advanced', True)
266266

267267

268-
@login_required
269-
def send_mail(request, project_slug):
268+
@user_passes_test(lambda u: u.is_superuser)
269+
def send_abandoned_mail(request, project_slug):
270270
"""Sends abandoned project email."""
271271
project = Project.objects.get(slug=project_slug)
272272
proj_name = project_slug
273-
for user in project.users.all():
274-
if AdminPermission.is_admin(user, project):
275-
email = user.email
276-
break
277273
context = {'proj_name': proj_name}
278274
subject = 'Rename request for abandoned project'
279-
send_email(
280-
recipient=email,
281-
subject=subject,
282-
template='projects/email/abandon_project.txt',
283-
template_html='projects/email/abandon_project.html',
284-
context=context)
275+
for user in project.users.all():
276+
email = user.email
277+
send_email(
278+
recipient=email,
279+
subject=subject,
280+
template='projects/email/abandon_project.txt',
281+
template_html='projects/email/abandon_project.html',
282+
context=context)
285283
project.abandoned_mail_sent = True
286284
project.save()
287285
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))

readthedocs/rtd_tests/tests/test_privacy_urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class PrivateProjectAdminAccessTest(PrivateProjectMixin, TestCase):
219219
# Places where we 302 on success -- These delete pages should probably be 405'ing
220220
'/dashboard/import/manual/demo/': {'status_code': 302},
221221
'/dashboard/pip/': {'status_code': 302},
222-
'/dashboard/pip/send_mail/': {'status_code':302},
222+
'/dashboard/pip/send_abandoned_mail/': {'status_code':302},
223223
'/dashboard/pip/subprojects/delete/sub/': {'status_code': 302},
224224
'/dashboard/pip/translations/delete/sub/': {'status_code': 302},
225225

@@ -254,7 +254,7 @@ class PrivateProjectUserAccessTest(PrivateProjectMixin, TestCase):
254254

255255
# Unauth access redirect for non-owners
256256
'/dashboard/pip/': {'status_code': 302},
257-
'/dashboard/pip/send_mail/': {'status_code':302},
257+
'/dashboard/pip/send_abandoned_mail/': {'status_code':302},
258258

259259
# 405's where we should be POST'ing
260260
'/dashboard/pip/users/delete/': {'status_code': 405},

readthedocs/templates/core/project_bar_base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ <h1>
2626

2727
{% if project.is_abandoned and request.user.is_superuser %}
2828
<div class="abandon=project">
29-
{% if not project.is_abandoned_mail_sent %}
30-
<form action="{% url "send_mail" project.slug %}" method="post">
29+
{% if not project.abandoned_mail_sent %}
30+
<form action="{% url "send_abandoned_mail" project.slug %}" method="post">
3131
{% csrf_token %}
3232
<input type="submit" name="submit-btn" value="{% trans "Email project owner with our abandoned project email" %}"/>
3333
</form>

0 commit comments

Comments
 (0)