Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
labels layout added to template
Browse files Browse the repository at this point in the history
  • Loading branch information
arojas1 committed Oct 2, 2023
1 parent 16ded78 commit cc39467
Show file tree
Hide file tree
Showing 2 changed files with 194 additions and 39 deletions.
17 changes: 12 additions & 5 deletions projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,24 @@ def embed_project(request, unique_id):
layout = request.GET.get('lt')
lang = request.GET.get('lang')

project = Project.objects.get(unique_id=unique_id)
project = project = Project.objects.prefetch_related(
'bc_labels',
'tk_labels',
'bc_labels__community',
'tk_labels__community',
'bc_labels__bclabel_translation',
'tk_labels__tklabel_translation',
).get(unique_id=unique_id)
notices = Notice.objects.filter(project=project, archived=False)
tk_labels = TKLabel.objects.filter(project_tklabels=project)
bc_labels = BCLabel.objects.filter(project_bclabels=project)
label_groups = return_project_labels_by_community(project)
# tk_labels = TKLabel.objects.filter(project_tklabels=project)
# bc_labels = BCLabel.objects.filter(project_bclabels=project)

context = {
'layout' : layout,
'lang' : lang,
'notices' : notices,
'tk_labels' : tk_labels,
'bc_labels' : bc_labels,
'label_groups' : label_groups,
'project' : project
}
return render(request, 'projects/embed-project.html', context)
216 changes: 182 additions & 34 deletions templates/projects/embed-project.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- Notices: http://localhost:8000/projects/embed/597bbfd7-2379-47e9-895b-e0db2353336f ?lt=1&lang=es -->
<!-- Notices: http://localhost:8000/projects/embed/597bbfd7-2379-47e9-895b-e0db2353336f -->
<!-- Labels: http://localhost:8000/projects/embed/f5850e3d-931e-46c0-9cb1-9969a4672271 -->
<!-- ?lt=1&lang=es -->
{% load static %}
<header>
<link rel="stylesheet" type="text/css" href="/static/css/main.css">
Expand All @@ -10,11 +12,24 @@
{% if notices %}
{% for notice in notices %}
<div class="margin-left-1 margin-right-1">
<img loading="lazy" class="img-sizedown-small pointer" src="{{ notice.img_url }}" alt="">
<img loading="lazy" class="margin-bottom-8 img-sizedown-small pointer" src="{{ notice.img_url }}" alt="">
</div>
{% endfor %}
{% endif %}

{% elif labels %}
{% if project.has_bclabels or project.has_tklabels %}
{% for community, labels in label_groups.items %}
{% for tklabel in labels.tk_labels %}
<div class="margin-left-1 margin-right-1">
<img loading="lazy" class="margin-bottom-8 img-sizedown-small pointer" src="{{ tklabel.img_url }}" alt="">
</div>
{% endfor %}
{% for bclabel in labels.bc_labels %}
<div class="margin-left-1 margin-right-1">
<img loading="lazy" class="margin-bottom-8 img-sizedown-small pointer" src="{{ bclabel.img_url }}" alt="">
</div>
{% endfor %}
{% endfor %}
{% endif %}
</div>
{% endif%}
Expand All @@ -24,68 +39,201 @@
<div class="flex-this wrap w-100">
{% if notices %}
{% for notice in notices %}
<div class="flex-this column center-text w-20 margin-left-8 margin-right-8 margin-top-1">
<div class="margin-left-1 margin-right-1">
<img loading="lazy" class="w-100 pointer" style="max-width:150px;min-width:50px;padding-right:5px;padding-left:5px;" src="{{ notice.img_url }}" alt="">
</div>
<div class="margin-left-1 margin-right-1">
{% if not lang or lang == 'en' %}
{% if not lang or lang == 'en' %}
<div class="flex-this column center-text w-20 margin-left-8 margin-right-8 margin-top-1">
<div class="margin-left-1 margin-right-1">
<img loading="lazy" class="w-100 pointer" style="max-width:150px;min-width:50px;padding:5px;" src="{{ notice.img_url }}" alt="">
</div>
<div class="margin-left-1 margin-right-1">
<p class="margin-top-8 margin-bottom-8 font-size-14">
{% if notice.notice_type == 'biocultural' %} Biocultural Notice{% endif %}
{% if notice.notice_type == 'traditional_knowledge' %} Traditional Knowledge Notice{% endif %}
{% if notice.notice_type == 'biocultural' %} Biocultural Notice{% endif %}
{% if notice.notice_type == 'attribution_incomplete' %} Attribution Incomplete Notice{% endif %}
</p>
</div>
</div>

{% else %}
{% for translation in notice.notice_translations.all %}
{% if lang == translation.language_tag %}
<div class="flex-this column center-text w-20 margin-left-8 margin-right-8 margin-top-1">
<div class="margin-left-1 margin-right-1">
<img loading="lazy" class="w-100 pointer" style="max-width:150px;min-width:50px;padding:5px;" src="{{ notice.img_url }}" alt="">
</div>
<div class="margin-left-1 margin-right-1">
<p class="margin-top-8 margin-bottom-8 font-size-14">{{ translation.translated_name }}</p>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}

{% if project.has_bclabels or project.has_tklabels %}
{% for community, labels in label_groups.items %}
{% for tklabel in labels.tk_labels %}
{% if not lang or lang == 'en' %}
<div class="flex-this column center-text w-20 margin-left-8 margin-right-8 margin-top-1">
<div class="margin-left-1 margin-right-1">
<img loading="lazy" class="w-100 pointer" style="max-width:150px;min-width:50px;padding:5px;" src="{{ tklabel.img_url }}" alt="">
</div>
<div class="margin-left-1 margin-right-1">
<p class="margin-top-8 margin-bottom-8 font-size-14">{{ tklabel.name }}</p>
</div>
</div>

{% for translation in notice.notice_translations.all %}
{% else %}
{% for translation in tklabel.tklabel_translation.all %}
{% if lang == translation.language_tag %}
<p class="margin-top-8 margin-bottom-8 font-size-14">{{ translation.translated_name }}</p>
<div class="flex-this column center-text w-20 margin-left-8 margin-right-8 margin-top-1">
<div class="margin-left-1 margin-right-1">
<img loading="lazy" class="w-100 pointer" style="max-width:150px;min-width:50px;padding:5px;" src="{{ tklabel.img_url }}" alt="">
</div>
<div class="margin-left-1 margin-right-1">
<p class="margin-top-8 margin-bottom-8 font-size-14">{{ translation.translated_name }}</p>
</div>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endfor %}
{% endif %}
{% endfor %}

{% elif labels %}
{% for bclabel in labels.bc_labels %}
{% if not lang or lang == 'en' %}
<div class="flex-this column center-text w-20 margin-left-8 margin-right-8 margin-top-1">
<div class="margin-left-1 margin-right-1">
<img loading="lazy" class="w-100 pointer" style="max-width:150px;min-width:50px;padding:5px;" src="{{ bclabel.img_url }}" alt="">
</div>
<div class="margin-left-1 margin-right-1">
<p class="margin-top-8 margin-bottom-8 font-size-14">{{ bclabel.name }}</p>
</div>
</div>

{% else %}
{% for translation in bclabel.bclabel_translation.all %}
{% if lang == translation.language_tag %}
<div class="flex-this column center-text w-20 margin-left-8 margin-right-8 margin-top-1">
<div class="margin-left-1 margin-right-1">
<img loading="lazy" class="w-100 pointer" style="max-width:150px;min-width:50px;padding:5px;" src="{{ bclabel.img_url }}" alt="">
</div>
<div class="margin-left-1 margin-right-1">
<p class="margin-top-8 margin-bottom-8 font-size-14">{{ translation.translated_name }}</p>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
</div>
{% endif%}

<!-- Full Text -->
{% if layout == "3" %}
<div class="flex-this wrap w-100">

{% if notices %}
{% for notice in notices %}
<div class="center-text flex-this wrap w-100">
<div class="w-20 auto-margin">
<img loading="lazy" class="w-100" style="max-width:150px;min-width:50px;padding-right:5px;padding-left:5px;" src="{{ notice.img_url }}" alt="">
</div>
<div style="text-align:left;padding-right:5px;" class="w-80 auto-margin">
{% if not lang or lang == 'en' %}
{% if not lang or lang == 'en' %}
<div class="center-text flex-this wrap w-100">
<div class="w-20 auto-margin">
<img loading="lazy" class="w-100" style="max-width:150px;min-width:50px;padding:5px;" src="{{ notice.img_url }}" alt="">
</div>
<div style="text-align:left;padding-right:5px;" class="w-80 auto-margin">
<h3 class=" padding-bottom-1 pad-top-1 no-top-margin no-bottom-margin">
{% if notice.notice_type == 'biocultural' %} Biocultural {% endif %}
{% if notice.notice_type == 'traditional_knowledge' %} Traditional Knowledge {% endif %}
{% if notice.notice_type == 'biocultural' %} Biocultural {% endif %}
{% if notice.notice_type == 'attribution_incomplete' %} Attribution Incomplete {% endif %}
</h3>
<h4 class="no-top-margin no-bottom-margin padding-bottom-1">English</h4>
<p class="no-top-margin">{{ notice.default_text }}</p>
</div>
</div>

{% else %}
{% for translation in notice.notice_translations.all %}
{% if lang == translation.language_tag %}
<div class="center-text flex-this wrap w-100">
<div class="w-20 auto-margin">
<img loading="lazy" class="w-100" style="max-width:150px;min-width:50px;padding:5px;" src="{{ notice.img_url }}" alt="">
</div>
<div style="text-align:left;padding-right:5px;" class="w-80 auto-margin">
<h3 class=" padding-bottom-1 pad-top-1 no-top-margin no-bottom-margin">{{ translation.translated_name }}</h3>
<h4 class="no-top-margin no-bottom-margin padding-bottom-1">{{ translation.language }}</h4>
<p class="no-top-margin">{{ translation.translated_text }}</p>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}

{% for translation in notice.notice_translations.all %}
{% if project.has_bclabels or project.has_tklabels %}
{% for community, labels in label_groups.items %}
{% for tklabel in labels.tk_labels %}
{% if not lang or lang == 'en' and lang == tklabel.language_tag %}
<div class="center-text flex-this wrap w-100">
<div class="w-20 auto-margin">
<img loading="lazy" class="w-100" style="max-width:150px;min-width:50px;padding:5px;" src="{{ tklabel.img_url }}" alt="">
</div>
<div style="text-align:left;padding-right:5px;" class="w-80 auto-margin">
<h3 class="padding-bottom-1 pad-top-1 no-top-margin no-bottom-margin">{{ tklabel.name}}</h3>
<h4 class="no-top-margin no-bottom-margin padding-bottom-1">{{ tklabel.language}}</h4>
<p class="no-top-margin">{{ tklabel.label_text}}</p>
</div>
</div>

{% else %}
{% for translation in tklabel.tklabel_translation.all %}
{% if lang == translation.language_tag %}
<h3 class=" padding-bottom-1 pad-top-1 no-top-margin no-bottom-margin">
{{ translation.translated_name }}
</h3>
<h4 class="no-top-margin no-bottom-margin padding-bottom-1">{{ translation.language }}</h4>
<p class="no-top-margin">{{ translation.translated_text }}</p>
<div class="center-text flex-this wrap w-100">
<div class="w-20 auto-margin">
<img loading="lazy" class="w-100" style="max-width:150px;min-width:50px;padding:5px;" src="{{ tklabel.img_url }}" alt="">
</div>
<div style="text-align:left;padding-right:5px;" class="w-80 auto-margin">
<h3 class="padding-bottom-1 pad-top-1 no-top-margin no-bottom-margin">{{ translation.translated_name }}</h3>
<h4 class="no-top-margin no-bottom-margin padding-bottom-1">{{ translation.language}}</h4>
<p class="no-top-margin">{{ translation.translated_text }}</p>
</div>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endfor %}
{% endif %}
{% endfor %}

{% for bclabel in labels.bc_labels %}
{% if not lang or lang == 'en' and lang == bclabel.language_tag %}
<div class="center-text flex-this wrap w-100">
<div class="w-20 auto-margin">
<img loading="lazy" class="w-100" style="max-width:150px;min-width:50px;padding:5px;" src="{{ bclabel.img_url }}" alt="">
</div>
<div style="text-align:left;padding-right:5px;" class="w-80 auto-margin">
<h3 class="padding-bottom-1 pad-top-1 no-top-margin no-bottom-margin">{{ bclabel.name}}</h3>
<h4 class="no-top-margin no-bottom-margin padding-bottom-1">{{ bclabel.language}}</h4>
<p class="no-top-margin">{{ bclabel.label_text}}</p>
</div>
</div>

{% elif labels %}
{% else %}
{% for translation in bclabel.bclabel_translation.all %}
{% if lang == translation.language_tag %}
<div class="center-text flex-this wrap w-100">
<div class="w-20 auto-margin">
<img loading="lazy" class="w-100" style="max-width:150px;min-width:50px;padding:5px;" src="{{ bclabel.img_url }}" alt="">
</div>
<div style="text-align:left;padding-right:5px;" class="w-80 auto-margin">
<h3 class="padding-bottom-1 pad-top-1 no-top-margin no-bottom-margin">{{ translation.translated_name }}</h3>
<h4 class="no-top-margin no-bottom-margin padding-bottom-1">{{ translation.language}}</h4>
<p class="no-top-margin">{{ translation.translated_text }}</p>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
</div>
{% endif %}
Expand Down

0 comments on commit cc39467

Please sign in to comment.