Skip to content
Open
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions ifcbdb/assets/vendor/summernote/summernote-bs4.min.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions ifcbdb/assets/vendor/summernote/summernote-bs4.min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 4.2.28 on 2026-03-25 12:00

from django.db import migrations


def convert_newlines_to_br(apps, schema_editor):
Dataset = apps.get_model('dashboard', 'Dataset')
Team = apps.get_model('dashboard', 'Team')

# Convert Dataset descriptions
for dataset in Dataset.objects.exclude(description__isnull=True).exclude(description=''):
if '<' not in dataset.description:
dataset.description = dataset.description.replace('\n', '<br />')
dataset.save(update_fields=['description'])

# Convert Team descriptions
for team in Team.objects.exclude(description__isnull=True).exclude(description=''):
if '<' not in team.description:
team.description = team.description.replace('\n', '<br />')
team.save(update_fields=['description'])


def reverse_br_to_newlines(apps, schema_editor):
Dataset = apps.get_model('dashboard', 'Dataset')
Team = apps.get_model('dashboard', 'Team')

# Reverse Dataset descriptions
for dataset in Dataset.objects.exclude(description__isnull=True).exclude(description=''):
dataset.description = dataset.description.replace('<br />', '\n').replace('<br>', '\n')
dataset.save(update_fields=['description'])

# Reverse Team descriptions
for team in Team.objects.exclude(description__isnull=True).exclude(description=''):
team.description = team.description.replace('<br />', '\n').replace('<br>', '\n')
team.save(update_fields=['description'])


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0052_team_short_description'),
]

operations = [
migrations.RunPython(
convert_newlines_to_br,
reverse_code=reverse_br_to_newlines
),
]
4 changes: 2 additions & 2 deletions ifcbdb/secure/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Meta:
"is_active": forms.CheckboxInput(attrs={"class": "custom-control-input"}),
"contact_name": forms.TextInput(attrs={"class": "form-control form-control-sm", "placeholder": "Contact Name"}),
"contact_email": forms.TextInput(attrs={"class": "form-control form-control-sm", "placeholder": "Contact Email"}),
"description": forms.Textarea(attrs={"class": "form-control form-control-sm", "placeholder": "Description"}),
"description": forms.Textarea(attrs={"class": "form-control form-control-sm summernote", "placeholder": "Description"}),
}

def clean_doi(self):
Expand Down Expand Up @@ -388,7 +388,7 @@ class Meta:
"name": forms.TextInput(attrs={"class": "form-control form-control-sm", "placeholder": "Name"}),
"title": forms.TextInput(attrs={"class": "form-control form-control-sm", "placeholder": "Title"}),
"default_dataset": forms.Select(attrs={"class": "form-control form-control-sm"}),
"description": forms.Textarea(attrs={"class": "form-control form-control-sm", "rows": 4}),
"description": forms.Textarea(attrs={"class": "form-control form-control-sm summernote", "rows": 4}),
"short_description": forms.TextInput(attrs={"class": "form-control form-control-sm"}),
}

Expand Down
4 changes: 2 additions & 2 deletions ifcbdb/templates/dashboard/_dataset-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ <h5><strong>
{% if dataset.description %}
<div>
<label>Description</label>
<span>{{ dataset.description|linebreaksbr }}</span>
<span>{{ dataset.description|safe }}</span>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion ifcbdb/templates/dashboard/empty-dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{% if dataset.description %}
<div class="mb-2">
<div class="d-block"><strong>Description</strong></div>
<div>{{ dataset.description|linebreaksbr }}</div>
<div>{{ dataset.description|safe }}</div>
</div>
{% endif %}
</div>
Expand Down
15 changes: 14 additions & 1 deletion ifcbdb/templates/secure/edit-dataset.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{% extends 'base.html' %}
{% load waffle_tags %}
{% load static %}

{% block extra_head %}
<title>{{ dataset.title }} » Manage</title>
<link href="{% static 'vendor/summernote/summernote-bs4.min.css' %}" rel="stylesheet">
{% endblock %}

{% block content %}
Expand Down Expand Up @@ -175,8 +177,19 @@
</div>

{% endblock %} {% block scripts %}

<script src="{% static 'vendor/summernote/summernote-bs4.min.js' %}"></script>
<script>
// Initialize Summernote on dataset description field
$('[name=description]').summernote({
placeholder: 'Enter the description...',
tabsize: 2,
height: 200,
toolbar: [
['font', ['bold', 'underline', 'italic']],
['insert', ['link']],
]
});

var _csrf = "{{ csrf_token }}";

{% if dataset.id > 0 and request.user.is_superuser %}
Expand Down
34 changes: 26 additions & 8 deletions ifcbdb/templates/secure/edit-team.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{% extends 'base.html' %}
{% load static %}

{% block extra_head %}
<link href="{% static 'vendor/summernote/summernote-bs4.min.css' %}" rel="stylesheet">
{% endblock %}

{% block content %}

Expand Down Expand Up @@ -34,8 +39,8 @@
{{ form.name }}
{% if form.name.errors %}<span class="text-danger">{{ form.name.errors.as_text }}</span>{% endif %}
{% else %}
<input type="hidden" name="name" value="{{ team.name }}" />
<input type="text" class="form-control form-control-sm" value="{{ team.name }}" disabled />
<input type="hidden" name="name" value="{{ team.name|default:"" }}" />
<input type="text" class="form-control form-control-sm" value="{{ team.name|default:"" }}" disabled />
{% endif %}
</div>
</div>
Expand All @@ -50,8 +55,8 @@
{{ form.title }}
{% if form.title.errors %}<span class="text-danger">{{ form.title.errors.as_text }}</span>{% endif %}
{% else %}
<input type="hidden" name="title" value="{{ team.title }}" />
<input type="text" class="form-control form-control-sm" value="{{ team.title }}" disabled />
<input type="hidden" name="title" value="{{ team.title|default:"" }}" />
<input type="text" class="form-control form-control-sm" value="{{ team.title|default:"" }}" disabled />
{% endif %}
</div>
</div>
Expand All @@ -66,8 +71,8 @@
{{ form.short_description }}
{% if form.short_description.errors %}<span class="text-danger">{{ form.short_description.errors.as_text }}</span>{% endif %}
{% else %}
<input type="hidden" name="short_description" value="{{ team.short_description }}" />
<textarea type="text" class="form-control form-control-sm" disabled>{{ team.short_description }}</textarea>
<input type="hidden" name="short_description" value="{{ team.short_description|default:"" }}" />
<textarea type="text" class="form-control form-control-sm" disabled>{{ team.short_description|default:"" }}</textarea>
{% endif %}
</div>
</div>
Expand All @@ -82,8 +87,8 @@
{{ form.description }}
{% if form.description.errors %}<span class="text-danger">{{ form.description.errors.as_text }}</span>{% endif %}
{% else %}
<input type="hidden" name="description" value="{{ team.description }}" />
<textarea type="text" class="form-control form-control-sm" rows="4" disabled>{{ team.description }}</textarea>
<input type="hidden" name="description" value="{{ team.description|default:"" }}" />
<textarea type="text" class="form-control form-control-sm" rows="4" disabled>{{ team.description|default:"" }}</textarea>
{% endif %}
</div>
</div>
Expand Down Expand Up @@ -198,7 +203,20 @@ <h5 class="modal-title" id="add-assigned-user-header"></h5>
{% endblock %}

{% block scripts %}
<script src="{% static 'vendor/summernote/summernote-bs4.min.js' %}"></script>
<script>
{% if is_admin %}
$('[name=description]').summernote({
placeholder: 'Enter the description...',
tabsize: 2,
height: 200,
toolbar: [
['font', ['bold', 'underline', 'italic']],
['insert', ['link']],
]
});
{% endif %}

let assignedUsers = JSON.parse(`{{ assigned_users_json|safe }}`);
let assignedUsersTable = null;

Expand Down