Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surface "abandoned" state on projects in UI #4995

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
09d8213
admin func for to update the abandoned project's slug
dojutsu-user Dec 13, 2018
d212759
add is_abandoned boolean field in Project model
dojutsu-user Dec 13, 2018
906d0c4
generate migrations file
dojutsu-user Dec 13, 2018
8f034b7
update admin action docs string and set is_abandoned flag
dojutsu-user Dec 13, 2018
c1c25ed
Add templates
dojutsu-user Dec 13, 2018
99dde0c
Add admin action for requesting namespace
dojutsu-user Dec 13, 2018
33c58ff
Add abandoned state on sidebar
dojutsu-user Dec 18, 2018
6378a4a
fix indentation
dojutsu-user Dec 18, 2018
62ef610
send an email notifying the user
dojutsu-user Dec 18, 2018
c699012
Add tests
dojutsu-user Dec 18, 2018
843f2a9
remove redundant import
dojutsu-user Dec 18, 2018
033f58b
use inbuilt notification system
dojutsu-user Dec 20, 2018
eb9a1af
Update tests with slight improvement
dojutsu-user Dec 20, 2018
b03400a
Add test for task
dojutsu-user Dec 20, 2018
4df938f
fix lint
dojutsu-user Dec 20, 2018
c36b421
Remove unnecessary imports
dojutsu-user Dec 20, 2018
b03d597
remove abandon_project_confirm.html/txt
dojutsu-user Dec 21, 2018
633be03
improve tests
dojutsu-user Dec 25, 2018
965d540
Add log.info
dojutsu-user Jan 5, 2019
ae2bda8
Merge branch 'master' into abandoned-projects-additions
dojutsu-user Jan 11, 2019
c4104b8
rename migrations file
dojutsu-user Jan 11, 2019
23c2123
Merge branch 'abandoned-projects-additions' of https://github.com/doj…
dojutsu-user Jan 11, 2019
8ee2d67
Merge branch 'master' into abandoned-projects-additions
dojutsu-user Jan 18, 2019
8d29c0b
Merge branch 'master' into abandoned-projects-additions
dojutsu-user Jan 22, 2019
236c37d
Merge branch 'master' into abandoned-projects-additions
dojutsu-user Jan 22, 2019
113e11e
Merge branch 'master' into abandoned-projects-additions
dojutsu-user Jan 24, 2019
d90bdd0
Merge branch 'master' into abandoned-projects-additions
dojutsu-user Feb 21, 2019
36dcb16
Rename migrations file
dojutsu-user Feb 21, 2019
cac446d
Merge master branch
dojutsu-user Mar 19, 2019
a67d640
fix imports
dojutsu-user Mar 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion readthedocs/projects/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
from django.contrib import admin, messages
from django.contrib.admin.actions import delete_selected
from django.utils.translation import ugettext_lazy as _
from django.db.models import F, Value
from django.db.models.functions import Concat
from guardian.admin import GuardedModelAdmin

from readthedocs.builds.models import Version
from readthedocs.core.models import UserProfile
from readthedocs.core.utils import broadcast
from readthedocs.notifications.views import SendNotificationView
from readthedocs.redirects.models import Redirect
from readthedocs.core.utils import send_email

from .forms import FeatureForm
from .models import (
Expand Down Expand Up @@ -126,7 +129,12 @@ class ProjectAdmin(GuardedModelAdmin):
VersionInline, DomainInline]
readonly_fields = ('feature_flags',)
raw_id_fields = ('users', 'main_language_project')
actions = ['send_owner_email', 'ban_owner']
actions = [
'send_owner_email',
'ban_owner',
'mark_as_abandoned',
'request_namespace',
]

def feature_flags(self, obj):
return ', '.join([str(f.get_feature_display()) for f in obj.features])
Expand Down Expand Up @@ -177,6 +185,40 @@ def delete_selected_and_artifacts(self, request, queryset):
broadcast(type='app', task=remove_dir, args=[project.doc_path])
return delete_selected(self, request, queryset)

def mark_as_abandoned(self, request, queryset):
"""
Marks selected projects as abandoned.

It adds '-abandoned' to the slug, marks
Project.is_abandoned and sends an email to the user
notifying the change and link to the new project/docs
page.
"""
queryset.update(
slug=Concat('slug', Value('-abandoned')),
dojutsu-user marked this conversation as resolved.
Show resolved Hide resolved
is_abandoned=True
)

mark_as_abandoned.short_description = 'Mark as abandoned'

def request_namespace(self, request, queryset):
"""Notify user that their project's namespace has been requested via email"""
qs_iterator = queryset.iterator()
for project in qs_iterator:
users = project.users.get_queryset()
for user in users:
send_email(
recipient=user.email,
dojutsu-user marked this conversation as resolved.
Show resolved Hide resolved
subject='Rename request for abandoned project',
template='projects/email/abandon_project.txt',
template_html='projects/email/abandon_project.html',
context={'proj_name': project.name}
)
success_msg = 'Email sent to {}'.format(user.email)
self.message_user(request, success_msg, level=messages.SUCCESS)

request_namespace.short_description = 'Request namespace'

def get_actions(self, request):
actions = super(ProjectAdmin, self).get_actions(request)
actions['delete_selected'] = (
Expand Down
20 changes: 20 additions & 0 deletions readthedocs/projects/migrations/0036_add_is_abandoned_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-12-13 10:35
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('projects', '0035_container_time_limit_as_integer'),
]

operations = [
migrations.AddField(
model_name='project',
name='is_abandoned',
field=models.BooleanField(default=False, verbose_name='Is abandoned'),
),
]
1 change: 1 addition & 0 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class Project(models.Model):
'Leave blank if you want us to find it for you.'))

featured = models.BooleanField(_('Featured'), default=False)
is_abandoned = models.BooleanField(_('Is abandoned'), default=False)
skip = models.BooleanField(_('Skip'), default=False)
install_project = models.BooleanField(
_('Install Project'),
Expand Down
19 changes: 19 additions & 0 deletions readthedocs/templates/projects/email/abandon_project.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "core/email/common.html" %}

{% block top-right %}
{{ proj_name }}
{% endblock %}

{% block content %}
<p>
We've had a request from one of our users for the project name {{ proj_name }} on Read the Docs. You are the current owner, and we wanted to reach out to you in accordance with our Abandoned Project policy (<a href="http://docs.readthedocs.io/en/latest/abandoned-projects.html">http://docs.readthedocs.io/en/latest/abandoned-projects.html</a>).
</p>

<p>
Since this is a fork of the existing owners project, {{ proj_name }}, you must show us the additional work that has been done in order to keep the new project name, that is different than the existing version of the project.
</p>

<p>
Please reply to this email either allowing or disallowing the transfer of the name on Read the Docs within 6 weeks, otherwise we will take the action of *initiating the transfer to a new owner* by default.
</p>
{% endblock %}
6 changes: 6 additions & 0 deletions readthedocs/templates/projects/email/abandon_project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "core/email/common.txt" %}
{% block content %}
We've had a request from one of our users for the project name {name} on Read the Docs. You are the current owner, and we wanted to reach out to you in accordance with our Abandoned Project policy (http://docs.readthedocs.io/en/latest/abandoned-projects.html).
Since this is a fork of the existing owners project, {name}, you must show us the additional work that has been done in order to keep the new project name, that is different than the existing version of the project.
Please reply to this email either allowing or disallowing the transfer of the name on Read the Docs within 6 weeks, otherwise we will take the action of *initiating the transfer to a new owner* by default.
{% endblock %}