<commit_before># -*- coding: utf-8 -*-
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © <NAME>. See NOTICE for more information.
#
from django import forms
from django.utils.translation import ugettext_lazy as _
from slughifi import slughifi

from catalogue.models import Tag, Book
from catalogue.fields import JQueryAutoCompleteField
from catalogue import utils


class BookImportForm(forms.Form):
    book_xml_file = forms.FileField()

    def save(self, commit=True):
        return Book.from_xml_file(self.cleaned_data['book_xml_file'], overwrite=True)


class SearchForm(forms.Form):
    q = JQueryAutoCompleteField('/katalog/tags/', {'minChars': 2, 'selectFirst': True, 'cacheLength': 50, 'matchContains': "word"})
    tags = forms.CharField(widget=forms.HiddenInput, required=False)

    def __init__(self, *args, **kwargs):
        tags = kwargs.pop('tags', [])
        super(SearchForm, self).__init__(*args, **kwargs)
        self.fields['q'].widget.attrs['title'] = _('title, author, theme/topic, epoch, kind, genre')
	self.fields['q'].widget.attrs['style'] = 'float: left; width: 200px; border: medium none; height: 15px; margin-top: 2px;'
        self.fields['tags'].initial = '/'.join(tag.slug for tag in Tag.get_tag_list(tags))


class UserSetsForm(forms.Form):
    def __init__(self, book, user, *args, **kwargs):<commit_msg>was throwing TypeError("save() got an unexpected keyword argument 'using'",)  before. <commit_after># -*- coding: utf-8 -*-
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © <NAME>. See NOTICE for more information.
#
from django import forms
from django.utils.translation import ugettext_lazy as _
from slughifi import slughifi

from catalogue.models import Tag, Book
from catalogue.fields import JQueryAutoCompleteField
from catalogue import utils


class BookImportForm(forms.Form):
    book_xml_file = forms.FileField()

    def save(self, commit=True, **kwargs):
        return Book.from_xml_file(self.cleaned_data['book_xml_file'], overwrite=True, **kwargs)


class SearchForm(forms.Form):
    q = JQueryAutoCompleteField('/katalog/tags/', {'minChars': 2, 'selectFirst': True, 'cacheLength': 50, 'matchContains': "word"})
    tags = forms.CharField(widget=forms.HiddenInput, required=False)

    def __init__(self, *args, **kwargs):
        tags = kwargs.pop('tags', [])
        super(SearchForm, self).__init__(*args, **kwargs)
        self.fields['q'].widget.attrs['title'] = _('title, author, theme/topic, epoch, kind, genre')
	self.fields['q'].widget.attrs['style'] = 'float: left; width: 200px; border: medium none; height: 15px; margin-top: 2px;'
        self.fields['tags'].initial = '/'.join(tag.slug for tag in Tag.get_tag_list(tags))


class UserSetsForm(forms.Form):
    def __init__(self, book, user, *args, **kwargs):
{'fraction_non_alphanumeric': 0.14180929095354522, 'fraction_numerical': 0.007684247293049249, 'mean_word_length': 4.716566866267465, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7450796', 'n_tokens_mistral': 911, 'n_tokens_neox': 877, 'n_words': 245}