Skip to content

Commit b95fb53

Browse files
authored
Merge pull request #8504 from readthedocs/juanlu/update-onboarding
Update onboarding
2 parents 0e5818a + 57e0812 commit b95fb53

File tree

9 files changed

+9
-202
lines changed

9 files changed

+9
-202
lines changed

docs/tutorial/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Preparing your project on GitHub
2424
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2525

2626
To start, `sign in to GitHub <https://github.com/login>`_
27-
and navigate to `the tutorial GitHub template <https://github.com/astrojuanlu/tutorial-template/>`_,
27+
and navigate to `the tutorial GitHub template <https://github.com/readthedocs/tutorial-template/>`_,
2828
where you will see a green :guilabel:`Use this template` button.
2929
Click it to open a new page that will ask you for some details:
3030

readthedocs/projects/backends/views.py

-6
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,3 @@
1515
class ImportWizardView(SettingsOverrideObject):
1616
_default_class = private.ImportWizardView
1717
_override_setting = 'PROJECT_IMPORT_VIEW'
18-
19-
20-
# Project demo import
21-
class ImportDemoView(SettingsOverrideObject):
22-
_default_class = private.ImportDemoView
23-
_override_setting = 'PROJECT_IMPORT_DEMO_VIEW'

readthedocs/projects/urls/private.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from django.views.generic.base import RedirectView
77

88
from readthedocs.constants import pattern_opts
9-
from readthedocs.projects.backends.views import ImportDemoView, ImportWizardView
9+
from readthedocs.projects.backends.views import ImportWizardView
1010
from readthedocs.projects.views import private
1111
from readthedocs.projects.views.private import (
1212
AutomationRuleDelete,
@@ -58,10 +58,6 @@
5858
r'^import/manual/$', ImportWizardView.as_view(),
5959
name='projects_import_manual',
6060
),
61-
url(
62-
r'^import/manual/demo/$', ImportDemoView.as_view(),
63-
name='projects_import_demo',
64-
),
6561
url(
6662
r'^(?P<project_slug>[-\w]+)/$',
6763
login_required(

readthedocs/projects/views/private.py

-66
Original file line numberDiff line numberDiff line change
@@ -343,72 +343,6 @@ def is_advanced(self):
343343
return data.get('advanced', True)
344344

345345

346-
class ImportDemoView(PrivateViewMixin, ProjectImportMixin, View):
347-
348-
"""View to pass request on to import form to import demo project."""
349-
350-
form_class = ProjectBasicsForm
351-
request = None
352-
args = None
353-
kwargs = None
354-
355-
def get(self, request, *args, **kwargs):
356-
"""Process link request as a form post to the project import form."""
357-
self.request = request
358-
self.args = args
359-
self.kwargs = kwargs
360-
361-
data = self.get_form_data()
362-
project = Project.objects.for_admin_user(
363-
request.user,
364-
).filter(repo=data['repo']).first()
365-
if project is not None:
366-
messages.success(
367-
request,
368-
_('The demo project is already imported!'),
369-
)
370-
else:
371-
kwargs = self.get_form_kwargs()
372-
form = self.form_class(data=data, **kwargs)
373-
if form.is_valid():
374-
project = form.save()
375-
project.save()
376-
self.trigger_initial_build(project, request.user)
377-
messages.success(
378-
request,
379-
_('Your demo project is currently being imported'),
380-
)
381-
else:
382-
messages.error(
383-
request,
384-
_('There was a problem adding the demo project'),
385-
)
386-
return HttpResponseRedirect(reverse('projects_dashboard'))
387-
return HttpResponseRedirect(
388-
reverse('projects_detail', args=[project.slug]),
389-
)
390-
391-
def get_form_data(self):
392-
"""Get form data to post to import form."""
393-
return {
394-
'name': '{}-demo'.format(self.request.user.username),
395-
'repo_type': 'git',
396-
'repo': 'https://github.com/readthedocs/template.git',
397-
}
398-
399-
def get_form_kwargs(self):
400-
"""Form kwargs passed in during instantiation."""
401-
return {'user': self.request.user}
402-
403-
def trigger_initial_build(self, project, user):
404-
"""
405-
Trigger initial build.
406-
407-
Allow to override the behavior from outside.
408-
"""
409-
return trigger_build(project)
410-
411-
412346
class ImportView(PrivateViewMixin, TemplateView):
413347

414348
"""

readthedocs/rtd_tests/tests/test_project_views.py

-114
Original file line numberDiff line numberDiff line change
@@ -346,120 +346,6 @@ def test_form_spam_ban_user(self, mocked_validator):
346346
self.assertTrue(self.user.profile.banned)
347347

348348

349-
@mock.patch('readthedocs.projects.views.private.trigger_build', mock.MagicMock())
350-
class TestImportDemoView(TestCase):
351-
"""Test project import demo view."""
352-
353-
fixtures = ['test_data', 'eric']
354-
355-
def setUp(self):
356-
self.client.login(username='eric', password='test')
357-
358-
def test_import_demo_pass(self):
359-
resp = self.client.get('/dashboard/import/manual/demo/')
360-
self.assertEqual(resp.status_code, 302)
361-
self.assertEqual(resp['Location'], '/projects/eric-demo/')
362-
resp_redir = self.client.get(resp['Location'])
363-
self.assertEqual(resp_redir.status_code, 200)
364-
messages = list(resp_redir.context['messages'])
365-
self.assertEqual(messages[0].level, message_const.SUCCESS)
366-
367-
def test_import_demo_already_imported(self):
368-
"""Import demo project multiple times, expect failure 2nd post."""
369-
self.test_import_demo_pass()
370-
project = Project.objects.get(slug='eric-demo')
371-
372-
resp = self.client.get('/dashboard/import/manual/demo/')
373-
self.assertEqual(resp.status_code, 302)
374-
self.assertEqual(resp['Location'], '/projects/eric-demo/')
375-
376-
resp_redir = self.client.get(resp['Location'])
377-
self.assertEqual(resp_redir.status_code, 200)
378-
messages = list(resp_redir.context['messages'])
379-
self.assertEqual(messages[0].level, message_const.SUCCESS)
380-
381-
self.assertEqual(
382-
project,
383-
Project.objects.get(slug='eric-demo'),
384-
)
385-
386-
def test_import_demo_another_user_imported(self):
387-
"""Import demo project after another user, expect success."""
388-
self.test_import_demo_pass()
389-
project = Project.objects.get(slug='eric-demo')
390-
391-
self.client.logout()
392-
self.client.login(username='test', password='test')
393-
resp = self.client.get('/dashboard/import/manual/demo/')
394-
self.assertEqual(resp.status_code, 302)
395-
self.assertEqual(resp['Location'], '/projects/test-demo/')
396-
397-
resp_redir = self.client.get(resp['Location'])
398-
self.assertEqual(resp_redir.status_code, 200)
399-
messages = list(resp_redir.context['messages'])
400-
self.assertEqual(messages[0].level, message_const.SUCCESS)
401-
402-
def test_import_demo_imported_renamed(self):
403-
"""If the demo project is renamed, don't import another."""
404-
self.test_import_demo_pass()
405-
project = Project.objects.get(slug='eric-demo')
406-
project.name = 'eric-demo-foobar'
407-
project.save()
408-
409-
resp = self.client.get('/dashboard/import/manual/demo/')
410-
self.assertEqual(resp.status_code, 302)
411-
self.assertEqual(resp['Location'], '/projects/eric-demo/')
412-
413-
resp_redir = self.client.get(resp['Location'])
414-
self.assertEqual(resp_redir.status_code, 200)
415-
messages = list(resp_redir.context['messages'])
416-
self.assertEqual(messages[0].level, message_const.SUCCESS)
417-
self.assertRegex(
418-
messages[0].message,
419-
r'already imported',
420-
)
421-
422-
self.assertEqual(
423-
project,
424-
Project.objects.get(slug='eric-demo'),
425-
)
426-
427-
def test_import_demo_imported_duplicate(self):
428-
"""
429-
If a project exists with same name, expect a failure importing demo.
430-
431-
This should be edge case, user would have to import a project (not the
432-
demo project), named user-demo, and then manually enter the demo import
433-
URL, as the onboarding isn't shown when projects > 0
434-
"""
435-
self.test_import_demo_pass()
436-
project = Project.objects.get(slug='eric-demo')
437-
project.repo = 'file:///foobar'
438-
project.save()
439-
440-
# Setting the primary and verified email of the test user.
441-
user = User.objects.get(username='eric')
442-
user_email = get(EmailAddress, user=user, primary=True, verified=True)
443-
444-
resp = self.client.get('/dashboard/import/manual/demo/')
445-
self.assertEqual(resp.status_code, 302)
446-
self.assertEqual(resp['Location'], '/dashboard/')
447-
448-
resp_redir = self.client.get(resp['Location'])
449-
self.assertEqual(resp_redir.status_code, 200)
450-
messages = list(resp_redir.context['messages'])
451-
self.assertEqual(messages[0].level, message_const.ERROR)
452-
self.assertRegex(
453-
messages[0].message,
454-
r'There was a problem',
455-
)
456-
457-
self.assertEqual(
458-
project,
459-
Project.objects.get(slug='eric-demo'),
460-
)
461-
462-
463349
@mock.patch('readthedocs.core.utils.trigger_build', mock.MagicMock())
464350
class TestPublicViews(TestCase):
465351
def setUp(self):

readthedocs/rtd_tests/tests/test_views.py

-4
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ def test_import_wizard_manual(self):
8383
response = self.client.get('/dashboard/import/manual/')
8484
self.assertRedirectToLogin(response)
8585

86-
def test_import_wizard_demo(self):
87-
response = self.client.get('/dashboard/import/manual/demo/')
88-
self.assertRedirectToLogin(response)
89-
9086
def test_edit(self):
9187
response = self.client.get('/dashboard/pip/edit/')
9288
self.assertRedirectToLogin(response)

readthedocs/templates/base.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ <h4>{% trans 'Resources' %}</h4>
168168

169169
<ul>
170170
<li>
171-
<a href="https://docs.readthedocs.io/page/intro/getting-started-with-sphinx.html">{% trans 'Getting Started Guide' %}</a>
171+
<a href="https://docs.readthedocs.io/page/tutorial/">{% trans 'Tutorial' %}</a>
172172
</li>
173173
<li>
174174
<a href="https://docs.readthedocs.io/page/team.html">{% trans 'Team' %}</a>

readthedocs/templates/homepage.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ <h3>Multiple versions</h3>
106106
<!-- Call to action -->
107107
<section>
108108
<p style="text-align: center">
109-
<a href="https://docs.readthedocs.io/page/intro/getting-started-with-sphinx.html" class="cta-btn">{% trans 'Getting started guide' %}</a>
109+
<a href="https://docs.readthedocs.io/page/tutorial/" class="cta-btn">{% trans 'Read the Tutorial' %}</a>
110110
</p>
111111
</section>
112112

readthedocs/templates/projects/onboard_import.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
<div class="onboard onboard-import-project">
55
<h2>{% trans "Ready to share your documentation" %}{% if request.user.first_name %}, {{ request.user.first_name }}{% endif %}?</h2>
66

7-
{% with getting_started_url="https://docs.readthedocs.io/page/intro/getting-started-with-sphinx.html" %}
7+
{% with tutorial_url="https://docs.readthedocs.io/page/tutorial/" template_project_url="https://github.com/readthedocs/tutorial-template/" %}
88
<form method="get" action="{% url "projects_import" %}">
99
<p>
1010
{% blocktrans trimmed %}
1111
You don't have any projects yet, but you can start building documentation by importing one.
1212
Not sure how to start documenting your project?
13-
Check out the <a href="{{ getting_started_url }}">Getting Started Guide</a> to learn how.
13+
Check out the <a href="{{ tutorial_url }}">Tutorial</a> to learn how.
1414
{% endblocktrans %}
1515
</p>
1616

1717
<p>
18-
{% url "projects_import_demo" as import_demo_url %}
18+
{% url "projects_import" as projects_import_url %}
1919
{% blocktrans trimmed %}
20-
Want to try a demo? <a href="{{ import_demo_url }}">Import our own demo project</a>.
20+
In a hurry? <a href="{{ template_project_url }}">Fork our template project</a> on Github,
21+
and <a href="{{ projects_import_url }}">import it</a>.
2122
{% endblocktrans %}
2223
</p>
2324

0 commit comments

Comments
 (0)