Skip to content

Commit

Permalink
refactor: cleanup apis_entities.edit_generic + template
Browse files Browse the repository at this point in the history
This replaces some context data with attributes from the instance and
removes some imports that were not used.
  • Loading branch information
b1rger committed Dec 12, 2023
1 parent 9115fc9 commit 7067731
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 49 deletions.
13 changes: 1 addition & 12 deletions apis_core/apis_entities/edit_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,12 @@
from django.views import View
from django.views.generic import DeleteView
from django_tables2 import RequestConfig
from reversion.models import Version

from apis_core.apis_labels.models import Label
from apis_core.apis_metainfo.models import Uri
from apis_core.apis_relations.models import TempTriple
from apis_core.apis_relations.tables import (
get_generic_triple_table,
LabelTableEdit,
)
from apis_core.apis_relations.tables import get_generic_triple_table, LabelTableEdit
from .forms import get_entities_form, GenericEntitiesStanbolForm
from .views import set_session_variables
from ..apis_vocabularies.models import TextType
from apis_core.utils import caching
from apis_core.utils import helpers
from apis_core.utils.settings import get_entity_settings_by_modelname
from apis_core.apis_entities.mixins import EntityMixin, EntityInstanceMixin
Expand Down Expand Up @@ -103,21 +96,17 @@ def get(self, request, *args, **kwargs):
apis_bibsonomy = "|".join([x.strip() for x in apis_bibsonomy])
else:
apis_bibsonomy = False
object_lod = Uri.objects.filter(root_object=self.instance)
object_labels = Label.objects.filter(temp_entity__id=self.instance.id)
tb_label = LabelTableEdit(
data=object_labels, prefix=self.entity.title()[:2] + "L-"
)
tb_label_open = request.GET.get("PL-page", None)
# side_bar.append(('Label', tb_label, 'PersonLabel', tb_label_open))
RequestConfig(request, paginate={"per_page": 10}).configure(tb_label)
template = get_template("apis_entities/edit_generic.html")
context = {
"entity_type": self.entity,
"form": form,
"instance": self.instance,
"right_card": side_bar,
"object_lod": object_lod,
"apis_bibsonomy": apis_bibsonomy,
}
form_merge_with = GenericEntitiesStanbolForm(self.entity, ent_merge_pk=self.pk)
Expand Down
48 changes: 11 additions & 37 deletions apis_core/apis_entities/templates/apis_entities/edit_generic.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,43 +58,6 @@ <h3>

{% crispy form %}

{% block linkedOpenData %}

{% if object_lod %}
<div class="card card-default">
<div class="card-header" role="tab" id="headingSix">
<h4 class="card-title">
<a role="button"
data-toggle="collapse"
data-parent="#accordion"
href="#collapseOne3"
aria-expanded="false"
aria-controls="collapseOne3">Linked Open Data</a>
</h4>
</div>
<div id="collapseOne3"
class="card-collapse collapse"
role="tabcard"
aria-labelledby="headingSix">
<div id="tab_Revisions" class="card-body">
<p>
{% for lod in object_lod %}

{% if forloop.last %}
<a href="{{ lod.uri }}">{{ lod.uri }}</a>
{% else %}
<a href="{{ lod.uri }}">{{ lod.uri }}</a>
<br />
{% endif %}

{% endfor %}
</p>
</div>
</div>
</div>
{% endif %}

{% endblock %}

{% block editbuttons %}
<div class="mt-2">
Expand All @@ -110,6 +73,17 @@ <h4 class="card-title">
{% endblock editbuttons %}

</form>
</div>
<div class="card-footer">
{% block linkedOpenData %}
<h5 class="card-title">Linked Open Data</h5>
{% if instance.uri_set %}
<ul>
{% for uri in instance.uri_set.all %}<li>{{ uri.uri | urlize }}</li>{% endfor %}
</ul>
{% endif %}

{% endblock %}
</div>
</div>
</div>
Expand Down

0 comments on commit 7067731

Please sign in to comment.