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

Issue #114 related project #161

Merged
merged 11 commits into from
Aug 14, 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
16 changes: 16 additions & 0 deletions geonode/base/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
ThesaurusKeywordLabel,
ThesaurusLabel,
TopicCategory,
RelatedProject,
)
from geonode.base.widgets import TaggitSelect2Custom, TaggitProfileSelect2Custom
from geonode.base.fields import MultiThesauriField
Expand Down Expand Up @@ -237,6 +238,20 @@ def clean(self):
return cleaned_data


class RelatedProjectForm(forms.ModelForm):
prefix = "related_project_form"

class Meta:
model = RelatedProject
fields = ["display_name"]

display_name = forms.ModelMultipleChoiceField(
RelatedProject.objects.all(),
# widget=forms.CheckboxSelectMultiple,
required=False,
)


class TKeywordForm(forms.ModelForm):
prefix = "tkeywords"

Expand Down Expand Up @@ -741,6 +756,7 @@ class Meta:
"was_published",
"funders",
"related_identifier",
"related_projects",
)


Expand Down
10 changes: 9 additions & 1 deletion geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,9 @@ class RelatedProject(models.Model):
max_length=255, help_text=_("Name of the hierarchy levels for which the metadata is provided. (e.g. signal)")
)

def __str__(self):
return f"{self.display_name}"


class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
"""
Expand Down Expand Up @@ -1149,7 +1152,12 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
Funder, verbose_name=_("Funder names"), null=True, blank=True, help_text=funders_help_text
)
related_projects = models.ManyToManyField(
RelatedProject, verbose_name=_("Related project"), null=True, blank=True, help_text=related_projects_help_text
RelatedProject,
null=True,
blank=True,
help_text=related_projects_help_text,
related_name="related_projects",
verbose_name=_("Related Project"),
)

use_contraints = models.TextField(
Expand Down
243 changes: 136 additions & 107 deletions geonode/layers/templates/datasets/dataset_metadata_advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
{{ block.super }}

<!-- Required to make select2 fields work for autocomplete -->
<link href="{% static "geonode/css/custom-bootstrap3.css" %}" type="text/css" media="screen" rel="stylesheet" />
<link href="{% static "geonode/css/filter_multi_select.css" %}" type="text/css" media="screen" rel="stylesheet" />
<link href="{% static "vendor/select2/dist/css/select2.css" %}" type="text/css" media="screen" rel="stylesheet" />
<link href="{% static "autocomplete_light/select2.css" %}" type="text/css" media="screen" rel="stylesheet" />
<script type="text/javascript" src="{% static "admin/js/vendor/jquery/jquery.js" %}"></script>
Expand Down Expand Up @@ -126,10 +128,29 @@ <h2 class="page-title">{% trans "Edit Metadata" %}</h2>
{% endif %}
{% endblock thesauri %}
</div>
{% block related_project_form %}
<div class="row">
<div class="col-md-12">
<label class="control-label required-field" >Project List </label>
<div class="form_item_spacing" id="related_project">
{% for field in related_project_form %}
<div>
{{field}}
</div>
{% endfor %}

</div>
</div>
</div>
{% endblock related_project_form %}

{% block funder_form %}
<label > Fundings</label>
<div id="form_funder">

<div class="row">
<div class="col-md-12" id="form_funder">

<label class="control-label required-field ">Fundings</label>

{{funder_form.management_form }}
<div id="DELETE" class="form-group">
</div>
Expand Down Expand Up @@ -233,117 +254,122 @@ <h2 class="page-title">{% trans "Edit Metadata" %}</h2>
</div>
</div>

</div>
</div>
</div>
{% endblock funder_form %}

{% block related_identifier_form %}
<label > Related Identifiers</label>
<div id="form_related_identifier">
{{related_identifier_form.management_form }}
<div id="DELETE" class="form-group">
</div>
<div class="panel ">
<!-- Tab panes -->
<div class="panel-heading panel-heading-nav">
<ul class="nav nav-tabs allTabs">
{% for form in related_identifier_form %}
{% if forloop.counter == 1 %}
<li role="presentation" class="active">
<a href="#{{ form.prefix }}" aria-controls="{{ form.prefix }}" role="tab" data-toggle="tab">
<span class="tabTex">{{ forloop.counter }} </span>
<button type="button" class="nav-remove" onclick="removeTab(this)"><icon class="fa fa-minus-circle"></icon>
</button></a>
</li>
{% else %}
<li role="presentation" class="">
<a href="#{{ form.prefix }}" aria-controls="{{ form.prefix }}" role="tab" data-toggle="tab">
<span class="tabTex">{{ forloop.counter }} </span>
<button type="button" class="nav-remove" onclick="removeTab(this)"><icon class="fa fa-minus-circle"></icon>
</button></a>
</li>
{% endif %}
{%endfor%}
<li role="presentation" class="nav-item enpt tab li-add" >
<a ><button id="nav-add" class="btn-primary nav-add " onclick="addNewTab(this)" type="button"><icon class="fa fa-plus-circle"> new </button></a>
</li>
<li role="presentation" class="nav-item enpt tab nav-empty templateTab hidden" >
<a href="" aria-controls="{{ form.prefix }}" role="tab" data-toggle="tab">
<span class="newTabTex"></span>
<button type="button" class="nav-remove" onclick="removeTab(this)" ><icon class="fa fa-minus-circle"></icon>
</button></a>
</li>

</ul>
<div class="row">
<div class="col-md-12">

<label class="control-label required-field"> Related Identifiers</label>
<div id="form_related_identifier">
{{related_identifier_form.management_form }}
<div id="DELETE" class="form-group">
</div>
<!-- Tab panes -->
<div class="tab-content allContent">
{% for form in related_identifier_form %}
{% if forloop.counter == 1 %}
<div class="tab-pane active" id="{{ form.prefix }}" role="tabpanel" >
<div>
{% if forloop.first %}

{% for field in form.visible_fields %}

<label for="{{ field.name }}">{{ field.label|capfirst }}</label>
<div id="{{ field.name }}" class="form-group">
{{ field }}
{{ field.errors.as_ul }}
</div>

{% endfor %}
{% endif %}
{% for hidden in form.hidden_fields %}
<div>
{{ hidden }}
</div>
{% endfor %}
</div>
</div>
{% else %}
<div class="tab-pane " id="{{ form.prefix }}" role="tabpanel" >
<div>

{% for field in form.visible_fields %}
<label for="{{ field.name }}">{{ field.label|capfirst }}</label>
<div id="{{ field.name }}" class="form-group">
{{ field }}
{{ field.errors.as_ul }}
</div>
{% endfor %}
{% for hidden in form.hidden_fields %}
<div>
{{ hidden }}
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
<div class="panel ">
<!-- Tab panes -->
<div class="panel-heading panel-heading-nav">
<ul class="nav nav-tabs allTabs">
{% for form in related_identifier_form %}
{% if forloop.counter == 1 %}
<li role="presentation" class="active">
<a href="#{{ form.prefix }}" aria-controls="{{ form.prefix }}" role="tab" data-toggle="tab">
<span class="tabTex">{{ forloop.counter }} </span>
<button type="button" class="nav-remove" onclick="removeTab(this)"><icon class="fa fa-minus-circle"></icon>
</button></a>
</li>
{% else %}
<li role="presentation" class="">
<a href="#{{ form.prefix }}" aria-controls="{{ form.prefix }}" role="tab" data-toggle="tab">
<span class="tabTex">{{ forloop.counter }} </span>
<button type="button" class="nav-remove" onclick="removeTab(this)"><icon class="fa fa-minus-circle"></icon>
</button></a>
</li>
{% endif %}
{%endfor%}
<li role="presentation" class="nav-item enpt tab li-add" >
<a ><button id="nav-add" class="btn-primary nav-add " onclick="addNewTab(this)" type="button"><icon class="fa fa-plus-circle"> new </button></a>
</li>
<li role="presentation" class="nav-item enpt tab nav-empty templateTab hidden" >
<a href="" aria-controls="{{ form.prefix }}" role="tab" data-toggle="tab">
<span class="newTabTex"></span>
<button type="button" class="nav-remove" onclick="removeTab(this)" ><icon class="fa fa-minus-circle"></icon>
</button></a>
</li>

<div class="tab-pane hidden templateContent" id="templateContent" role="tabpanel" >
<div>

{% for field in related_identifier_form.empty_form.visible_fields %}
<label for="{{ field.name }}">{{ field.label|capfirst }}</label>
<div id="{{ field.name }}" class="form-group">
{{ field }}
{{ field.errors.as_ul }}
</div>
{% endfor %}
{% for hidden in related_identifier_form.empty_form.hidden_fields %}
<div>
{{ hidden }}
</div>
{% endfor %}
</ul>
</div>
<!-- Tab panes -->
<div class="tab-content allContent">
{% for form in related_identifier_form %}
{% if forloop.counter == 1 %}
<div class="tab-pane active" id="{{ form.prefix }}" role="tabpanel" >
<div>
{% if forloop.first %}

{% for field in form.visible_fields %}

<label for="{{ field.name }}">{{ field.label|capfirst }}</label>
<div id="{{ field.name }}" class="form-group">
{{ field }}
{{ field.errors.as_ul }}
</div>

{% endfor %}
{% endif %}
{% for hidden in form.hidden_fields %}
<div>
{{ hidden }}
</div>
{% endfor %}
</div>
</div>
</div>

</div>
{% else %}
<div class="tab-pane " id="{{ form.prefix }}" role="tabpanel" >
<div>

{% for field in form.visible_fields %}
<label for="{{ field.name }}">{{ field.label|capfirst }}</label>
<div id="{{ field.name }}" class="form-group">
{{ field }}
{{ field.errors.as_ul }}
</div>
{% endfor %}
{% for hidden in form.hidden_fields %}
<div>
{{ hidden }}
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}

<div class="tab-pane hidden templateContent" id="templateContent" role="tabpanel" >
<div>

{% for field in related_identifier_form.empty_form.visible_fields %}
<label for="{{ field.name }}">{{ field.label|capfirst }}</label>
<div id="{{ field.name }}" class="form-group">
{{ field }}
{{ field.errors.as_ul }}
</div>
{% endfor %}
{% for hidden in related_identifier_form.empty_form.hidden_fields %}
<div>
{{ hidden }}
</div>
{% endfor %}
</div>
</div>

</div>
</div>

</div>

</div>

</div>
</div>
{% endblock related_identifier_form %}


Expand Down Expand Up @@ -488,6 +514,9 @@ <h4 class="modal-title">{% trans "ERROR" %}</h4>
let formsetsInTabs = ["{{funder_form.prefix}}","{{related_identifier_form.prefix}}"];
</script>

{% comment %} <script type="text/javascript" src="{% static "geonode/js/utils/fundings_.js" %}"></script> {% endcomment %}

<script type="text/javascript" src="{% static "geonode/js/utils/filter-multi-select-bundle.min.js" %}"></script>
<script type="text/javascript" src="{% static "geonode/js/utils/formsetsInTabs.js" %}"></script>
<script type="text/javascript" src="{% static "geonode/js/utils/focus.js" %}"></script>

{% endblock %}
Loading
Loading