Basic email template for notifications #96
@ -328,6 +328,8 @@
|
|||||||
|
|
||||||
a
|
a
|
||||||
color: var(--color-text)
|
color: var(--color-text)
|
||||||
|
// TODO: @web-assets check arbitrary style table link display specificity
|
||||||
|
display: inline !important
|
||||||
+padding(1, y)
|
+padding(1, y)
|
||||||
padding-inline: 0 !important
|
padding-inline: 0 !important
|
||||||
|
|
||||||
|
@ -27,6 +27,16 @@
|
|||||||
<a href="{{ extension.get_absolute_url }}"><strong>{{ extension.name }}</strong></a>
|
<a href="{{ extension.get_absolute_url }}"><strong>{{ extension.name }}</strong></a>
|
||||||
</p>
|
</p>
|
||||||
<hr>
|
<hr>
|
||||||
|
{% if not extension and drafts %}
|
||||||
|
<div>
|
||||||
|
<span class="text-warning">You have unfinished drafts:</span>
|
||||||
|
<ul>
|
||||||
|
{% for d in drafts %}
|
||||||
|
<li><a href="{{ d.get_draft_url }}">{{ d }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<p>Please make sure that:</p>
|
<p>Please make sure that:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>You are the creator or maintainer</strong> of this extension.</li>
|
<li><strong>You are the creator or maintainer</strong> of this extension.</li>
|
||||||
|
@ -460,3 +460,15 @@ class NewVersionTest(TestCase):
|
|||||||
).count(),
|
).count(),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class DraftsWarningTest(TestCase):
|
||||||
|
fixtures = ['licenses']
|
||||||
|
|
||||||
|
def test_page_contains_warning(self):
|
||||||
|
version = create_version(extension__extension_id='draft_warning')
|
||||||
|
extension = version.extension
|
||||||
|
self.assertEqual(extension.status, Extension.STATUSES.INCOMPLETE)
|
||||||
|
self.client.force_login(extension.authors.all()[0])
|
||||||
|
response = self.client.get(reverse_lazy('extensions:submit'))
|
||||||
|
self.assertContains(response, extension.get_draft_url())
|
||||||
|
@ -14,7 +14,6 @@ from .mixins import (
|
|||||||
OwnsFileMixin,
|
OwnsFileMixin,
|
||||||
MaintainedExtensionMixin,
|
MaintainedExtensionMixin,
|
||||||
DraftVersionMixin,
|
DraftVersionMixin,
|
||||||
DraftMixin,
|
|
||||||
)
|
)
|
||||||
from extensions.forms import (
|
from extensions.forms import (
|
||||||
EditPreviewFormSet,
|
EditPreviewFormSet,
|
||||||
@ -104,7 +103,6 @@ class UpdateExtensionView(
|
|||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
MaintainedExtensionMixin,
|
MaintainedExtensionMixin,
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
DraftMixin,
|
|
||||||
UpdateView,
|
UpdateView,
|
||||||
):
|
):
|
||||||
model = Extension
|
model = Extension
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from django.contrib.auth.mixins import UserPassesTestMixin
|
from django.contrib.auth.mixins import UserPassesTestMixin
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
from extensions.models import Extension
|
from extensions.models import Extension
|
||||||
from files.models import File
|
from files.models import File
|
||||||
@ -60,27 +60,3 @@ class DraftVersionMixin:
|
|||||||
def dispatch(self, *args, **kwargs):
|
def dispatch(self, *args, **kwargs):
|
||||||
self.version = self.extension.versions.first()
|
self.version = self.extension.versions.first()
|
||||||
return super().dispatch(*args, **kwargs)
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class DraftMixin:
|
|
||||||
"""If the extension is incomplete, returns the FinalizeDraftView"""
|
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
|
||||||
if (
|
|
||||||
'slug' in kwargs
|
|
||||||
and Extension.objects.filter(
|
|
||||||
slug=kwargs['slug'], status=Extension.STATUSES.APPROVED
|
|
||||||
).first()
|
|
||||||
):
|
|
||||||
return super().dispatch(request, *args, **kwargs)
|
|
||||||
|
|
||||||
extension = (
|
|
||||||
Extension.objects.listed_or_authored_by(user_id=self.request.user.pk)
|
|
||||||
.filter(status=Extension.STATUSES.INCOMPLETE)
|
|
||||||
.first()
|
|
||||||
)
|
|
||||||
|
|
||||||
if not extension:
|
|
||||||
return super().dispatch(request, *args, **kwargs)
|
|
||||||
|
|
||||||
return redirect(extension.get_draft_url())
|
|
||||||
|
@ -4,7 +4,6 @@ from django.contrib.auth.mixins import LoginRequiredMixin
|
|||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.views.generic.edit import CreateView
|
from django.views.generic.edit import CreateView
|
||||||
|
|
||||||
from .mixins import DraftMixin
|
|
||||||
from extensions.models import Version, Extension
|
from extensions.models import Version, Extension
|
||||||
from files.forms import FileForm
|
from files.forms import FileForm
|
||||||
from files.models import File
|
from files.models import File
|
||||||
@ -12,11 +11,19 @@ from files.models import File
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class UploadFileView(LoginRequiredMixin, DraftMixin, CreateView):
|
class UploadFileView(LoginRequiredMixin, CreateView):
|
||||||
model = File
|
model = File
|
||||||
template_name = 'extensions/submit.html'
|
template_name = 'extensions/submit.html'
|
||||||
form_class = FileForm
|
form_class = FileForm
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
drafts = Extension.objects.authored_by(user_id=self.request.user.pk).filter(
|
||||||
|
status=Extension.STATUSES.INCOMPLETE
|
||||||
|
)
|
||||||
|
context['drafts'] = drafts
|
||||||
|
return context
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
kwargs = super().get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
kwargs['request'] = self.request
|
kwargs['request'] = self.request
|
||||||
|
Loading…
Reference in New Issue
Block a user