Skip to content

Update onboarding #8504

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

Merged
merged 5 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
6 changes: 0 additions & 6 deletions readthedocs/projects/backends/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,3 @@
class ImportWizardView(SettingsOverrideObject):
_default_class = private.ImportWizardView
_override_setting = 'PROJECT_IMPORT_VIEW'


# Project demo import
class ImportDemoView(SettingsOverrideObject):
_default_class = private.ImportDemoView
_override_setting = 'PROJECT_IMPORT_DEMO_VIEW'
6 changes: 1 addition & 5 deletions readthedocs/projects/urls/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.views.generic.base import RedirectView

from readthedocs.constants import pattern_opts
from readthedocs.projects.backends.views import ImportDemoView, ImportWizardView
from readthedocs.projects.backends.views import ImportWizardView
from readthedocs.projects.views import private
from readthedocs.projects.views.private import (
AutomationRuleDelete,
Expand Down Expand Up @@ -58,10 +58,6 @@
r'^import/manual/$', ImportWizardView.as_view(),
name='projects_import_manual',
),
url(
r'^import/manual/demo/$', ImportDemoView.as_view(),
name='projects_import_demo',
),
url(
r'^(?P<project_slug>[-\w]+)/$',
login_required(
Expand Down
66 changes: 0 additions & 66 deletions readthedocs/projects/views/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,72 +343,6 @@ def is_advanced(self):
return data.get('advanced', True)


class ImportDemoView(PrivateViewMixin, ProjectImportMixin, View):

"""View to pass request on to import form to import demo project."""

form_class = ProjectBasicsForm
request = None
args = None
kwargs = None

def get(self, request, *args, **kwargs):
"""Process link request as a form post to the project import form."""
self.request = request
self.args = args
self.kwargs = kwargs

data = self.get_form_data()
project = Project.objects.for_admin_user(
request.user,
).filter(repo=data['repo']).first()
if project is not None:
messages.success(
request,
_('The demo project is already imported!'),
)
else:
kwargs = self.get_form_kwargs()
form = self.form_class(data=data, **kwargs)
if form.is_valid():
project = form.save()
project.save()
self.trigger_initial_build(project, request.user)
messages.success(
request,
_('Your demo project is currently being imported'),
)
else:
messages.error(
request,
_('There was a problem adding the demo project'),
)
return HttpResponseRedirect(reverse('projects_dashboard'))
return HttpResponseRedirect(
reverse('projects_detail', args=[project.slug]),
)

def get_form_data(self):
"""Get form data to post to import form."""
return {
'name': '{}-demo'.format(self.request.user.username),
'repo_type': 'git',
'repo': 'https://github.com/readthedocs/template.git',
}

def get_form_kwargs(self):
"""Form kwargs passed in during instantiation."""
return {'user': self.request.user}

def trigger_initial_build(self, project, user):
"""
Trigger initial build.

Allow to override the behavior from outside.
"""
return trigger_build(project)


class ImportView(PrivateViewMixin, TemplateView):

"""
Expand Down
9 changes: 5 additions & 4 deletions readthedocs/templates/projects/onboard_import.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
<div class="onboard onboard-import-project">
<h2>{% trans "Ready to share your documentation" %}{% if request.user.first_name %}, {{ request.user.first_name }}{% endif %}?</h2>

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

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

Expand Down