X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/f9a071b288cec64a55000125a63b62a3b233c3fd..cf76dbd53927cb38154845748fb3481cf013970f:/src/social/forms.py diff --git a/src/social/forms.py b/src/social/forms.py index 8527915a6..f82e27c43 100644 --- a/src/social/forms.py +++ b/src/social/forms.py @@ -1,12 +1,10 @@ -# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # from django import forms -from django.utils.translation import gettext_lazy as _ from catalogue.models import Book, Tag -from catalogue import utils -from social.utils import get_set, set_sets +from social.utils import get_set class UserSetsForm(forms.Form): @@ -17,40 +15,6 @@ class UserSetsForm(forms.Form): ) -class ObjectSetsForm(forms.Form): - tags = forms.CharField(label=_('Tags (comma-separated)'), required=False, - widget=forms.Textarea()) - - def __init__(self, obj, user, *args, **kwargs): - self._obj = obj - self._user = user - data = kwargs.setdefault('data', {}) - if 'tags' not in data and user.is_authenticated: - data['tags'] = ', '.join( - obj.tags.filter(category='set', user=user).exclude(name__in=(None, '')).values_list('name', flat=True)) - super(ObjectSetsForm, self).__init__(*args, **kwargs) - - def save(self, request): - tags = [get_set(self._user, tag_name.strip()) for tag_name in self.cleaned_data['tags'].split(',')] - set_sets(self._user, self._obj, tags) - return {"like": True} - - -class NewSetForm(forms.Form): - name = forms.CharField(max_length=50, required=True) - - def __init__(self, *args, **kwargs): - super(NewSetForm, self).__init__(*args, **kwargs) - self.fields['name'].widget.attrs['title'] = _('Name of the new shelf') - - def save(self, user, commit=True): - name = self.cleaned_data['name'] - new_set = Tag(name=name, slug=utils.get_random_hash(name), sort_key=name.lower(), category='set', user=user) - - new_set.save() - return new_set - - class AddSetForm(forms.Form): name = forms.CharField(max_length=50) book = forms.IntegerField()