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

Passe à Django 4.2 #6577

Merged
merged 7 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 5 additions & 3 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ async function jsLint() {
console.log(resultText)
}

// Get JS minified files from packages
/* Get JS minified files from packages
* Get also sourcemaps for all JS files, required by Django's ManifestStaticFilesStorage since 4.1 (see
* https://docs.djangoproject.com/fr/4.2/ref/contrib/staticfiles/#manifeststaticfilesstorage) */
function jsPackages() {
return gulp.src([
require.resolve('jquery/dist/jquery.min.js'),
Expand All @@ -126,8 +128,8 @@ function jsPackages() {
require.resolve('chartjs-adapter-moment/dist/chartjs-adapter-moment.min.js'),
require.resolve('chart.js/dist/chart.min.js'),
require.resolve('easymde/dist/easymde.min.js')
])
.pipe(gulp.dest('dist/js/'))
], { sourcemaps: true })
.pipe(gulp.dest('dist/js/', { sourcemaps: '.' }))
}

// Generates JS for the website
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ beautifulsoup4==4.12.2
django-crispy-forms==2.0
django-model-utils==4.3.1
django-recaptcha==4.0.0
Django==3.2.23
Django==4.2.6
easy-thumbnails[svg]==2.8.5
factory-boy==3.3.0
geoip2==4.8.0
Expand Down
20 changes: 8 additions & 12 deletions zds/featured/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,20 +336,16 @@ def form_valid(self, form):


class FeaturedMessageDelete(FeaturedViewMixin, DeleteView):
"""
Delete the featured message.
"""

http_method_names = ["post", "delete"]
last_message = None
"""Delete the featured message."""

def dispatch(self, request, *args, **kwargs):
self.last_message = FeaturedMessage.objects.get_last_message()
return super().dispatch(request, *args, **kwargs)
http_method_names = ["post"]
model = FeaturedMessage

def delete(self, request, *args, **kwargs):
if self.last_message:
self.last_message.delete()
def get_object(self, queryset=None):
return FeaturedMessage.objects.get_last_message()

def form_valid(self, form):
if self.object is not None:
self.object.delete()
messages.success(self.request, _("Le message a été supprimé."))
return redirect(reverse("featured:resource-list"))
4 changes: 2 additions & 2 deletions zds/tutorialv2/views/containers_extracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ def form_valid(self, form):
class DeleteContainerOrExtract(LoggedWithReadWriteHability, SingleContentViewMixin, DeleteView):
model = PublishableContent
template_name = None
http_method_names = ["delete", "post"]
http_method_names = ["post"]
object = None
versioned_object = None

def delete(self, request, *args, **kwargs):
def form_valid(self, form):
"""delete any object, either Extract or Container"""
self.object = self.get_object()
self.versioned_object = self.get_versioned_object()
Expand Down
12 changes: 3 additions & 9 deletions zds/tutorialv2/views/contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
from zds.tutorialv2.models.database import PublishableContent, Validation
from zds.tutorialv2.utils import init_new_repo
from zds.tutorialv2.views.authors import RemoveAuthorFromContent
from zds.tutorialv2.views.goals import EditGoalsForm
from zds.tutorialv2.views.labels import EditLabelsForm
from zds.utils.models import get_hat_from_settings
from zds.mp.utils import send_mp, send_message_mp
from zds.utils.uuslug_wrapper import slugify
Expand Down Expand Up @@ -279,18 +277,14 @@ def form_valid(self, form):

class DeleteContent(LoginRequiredMixin, SingleContentViewMixin, DeleteView):
model = PublishableContent
template_name = None
http_method_names = ["delete", "post"]
object = None
http_method_names = ["post"]
authorized_for_staff = False # deletion is creator's privilege

@method_decorator(transaction.atomic)
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **kwargs)

def delete(self, request, *args, **kwargs):
"""rewrite delete() function to ensure repository deletion"""

def form_valid(self, form):
self.object = self.get_object()
object_type = self.object.type.lower()

Expand Down Expand Up @@ -362,4 +356,4 @@ def delete(self, request, *args, **kwargs):

messages.success(self.request, _("Vous avez bien supprimé {}.").format(_type))

return redirect(reverse(object_type + ":find-" + object_type, args=[request.user.username]))
return redirect(reverse(object_type + ":find-" + object_type, args=[self.request.user.username]))