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

birger/drop legacy stuff #85

Merged
merged 2 commits into from
Aug 26, 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
41 changes: 1 addition & 40 deletions apis_bibsonomy/forms.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,10 @@
from django.forms import ModelForm, HiddenInput
from django.urls import reverse
from django.forms import ModelForm
from .models import Reference
from dal.autocomplete import ListSelect2
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout, Row, Column, Div


class ReferenceForm(ModelForm):
class Meta:
model = Reference
fields = "__all__"
attrs = {"data-placeholder": "Type to get suggestions", "data-html": True}
widgets = {
"bibs_url": ListSelect2(url="bibsonomy:bibsonomyautocomplete", attrs=attrs)
}

def __init__(
self,
content_type=None,
object_pk=None,
attribute_name=None,
hidden=False,
*args,
**kwargs,
):
ModelForm.__init__(self, *args, **kwargs)
self.helper = FormHelper(self)
self.helper.add_input(Submit("submit", "Submit", css_class="btn-primary"))
self.helper.form_id = "bibs-form"
self.helper.form_class = "bibs-forms"
self.helper.form_action = reverse("bibsonomy:savegetbibsonomyentry")
self.fields["pages_start"].widget.attrs["class"] = "form-control"
self.fields["pages_end"].widget.attrs["class"] = "form-control"
self.fields["bibtex"].widget = HiddenInput()
self.fields["content_type"].widget = HiddenInput()
self.fields["attribute"].widget = HiddenInput()
self.fields["object_id"].widget = HiddenInput()
if content_type is not None:
self.fields["content_type"].initial = content_type
if object_pk is not None:
self.fields["object_id"].initial = object_pk
if attribute_name is not None:
self.fields["attribute"].initial = attribute_name


class ReferenceNewForm(ModelForm):
class Meta:
model = Reference
Expand Down
25 changes: 0 additions & 25 deletions apis_bibsonomy/templatetags/bibsonomy_templatetags.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,9 @@
from django import template
from apis_bibsonomy.forms import ReferenceForm
from django.contrib.contenttypes.models import ContentType

register = template.Library()


@register.inclusion_tag("apis_bibsonomy/form_tag.html", takes_context=False)
def bibsonomy_form(
content_type=None, object_pk=None, attribute_name=None, hidden=False
):
c_dict = {
"content_type": content_type,
"object_pk": object_pk,
"attribute_name": attribute_name,
}
form = ReferenceForm(**c_dict)
return {"form": form, "hidden": hidden}


@register.inclusion_tag("apis_bibsonomy/list_tag.html", takes_context=False)
def bibsonomy_list(content_type=None, object_pk=None, attribute_name=None):
c_dict = {
"content_type": content_type,
"object_pk": object_pk,
"attribute_name": attribute_name,
}
form = ReferenceForm(**c_dict)
return {"form": form}


@register.inclusion_tag(
"apis_bibsonomy/link_to_reference_on_tag.html", takes_context=False
)
Expand Down
Loading