Skip to content

Commit

Permalink
hm, where will this end?
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 committed Dec 10, 2023
1 parent f834099 commit e3652c3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 236 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "base.html" %}
{% load static %}
{% block titel %}Create a {{ entity_type|title }}{% endblock %}

{% block content %}
{% load django_tables2 %}
{% load crispy_forms_tags %}
<div class="container-fluid pt-2">
<h1 class="display-4 text-center">
<a href="{{ instance.get_listview_url }}">
<small>{{ entity_type }}s </small>
</a>
{{ instance }}
</h1>
<h2 class="text-center">
<a href="{{ instance.get_absolute_url }}">
<i class="bi bi-eye"></i>
</a>
<a href="/entity/{{ instance.id }}">
<i class="bi bi-database"></i>
</a>
</h2>
<div class="row">
<div class="col-md-5">
<h3 class="text-center">
Edit the Entity
</h3>
<form action="" method="post">
{% crispy form %}
<input class="btn btn-primary" type="submit" value="modify" />
<a class ="btn btn-danger btn-primary" href="delete">Delete</a>
</form>
</div>
<div class="col-md-7">
<h3 class="text-center">Edit the Relations</h3>
{% for obj in right_card %}
<div class="pt-2">
<h4 class="card-title">{{ obj.0 }}</h4>
<div id="tab_{{ obj.2 }}">
{% render_table obj.1 %}
</div>
</div>
{% endfor %}
</div>
</div>

{% endblock %}
22 changes: 3 additions & 19 deletions apis_core/apis_entities/views2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@

from apis_core.apis_entities.models import AbstractEntity
from apis_core.apis_labels.models import Label
from apis_core.apis_metainfo.models import Uri
from apis_core.apis_relations.models import AbstractRelation
from apis_core.apis_relations.tables import get_generic_relations_table, LabelTableEdit
from .forms import get_entities_form, FullTextForm, GenericEntitiesStanbolForm
from .views import get_highlighted_texts
from .views import set_session_variables


@method_decorator(login_required, name="dispatch")
Expand All @@ -29,7 +26,6 @@ def get(self, request, *args, **kwargs):
pk = kwargs["pk"]
entity_model = AbstractEntity.get_entity_class_of_name(entity)
instance = get_object_or_404(entity_model, pk=pk)
request = set_session_variables(request)
relations = AbstractRelation.get_relation_classes_of_entity_name(
entity_name=entity
)
Expand Down Expand Up @@ -69,36 +65,24 @@ def get(self, request, *args, **kwargs):
)
form = get_entities_form(entity.title())
form = form(instance=instance)
form_text = FullTextForm(entity=entity.title(), instance=instance)
form_ann_agreement = False
apis_bibsonomy = False
object_lod = Uri.objects.filter(entity=instance)
object_texts, ann_proj_form = get_highlighted_texts(request, instance)
object_labels = Label.objects.filter(temp_entity=instance)
tb_label = LabelTableEdit(data=object_labels, prefix=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 = select_template(
[
"apis_entities/{}_create_generic.html".format(entity),
"apis_entities/entity_create_generic.html",
"apis_entities/entity_edit_generic.html",
]
)
context = {
"entity_type": entity,
"form": form,
"form_text": form_text,
"instance": instance,
"right_card": side_bar,
"object_texts": object_texts,
"object_lod": object_lod,
"ann_proj_form": ann_proj_form,
"form_ann_agreement": form_ann_agreement,
"apis_bibsonomy": apis_bibsonomy,
}
form_merge_with = GenericEntitiesStanbolForm(entity, ent_merge_pk=pk)
context["form_merge_with"] = form_merge_with
# form_merge_with = GenericEntitiesStanbolForm(entity, ent_merge_pk=pk)
# context["form_merge_with"] = form_merge_with
return HttpResponse(template.render(request=request, context=context))

def post(self, request, *args, **kwargs):
Expand Down
7 changes: 5 additions & 2 deletions pmb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@
"django_extensions",
]

CSRF_USE_SESSIONS = True


MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
# "django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
Expand Down

0 comments on commit e3652c3

Please sign in to comment.