Skip to content

Commit

Permalink
Merge pull request #194 from rice-crc/feature/february
Browse files Browse the repository at this point in the history
Feature/february
  • Loading branch information
derekjkeller authored Mar 23, 2023
2 parents 59d967d + 51ded50 commit 7da3908
Show file tree
Hide file tree
Showing 41 changed files with 68,451 additions and 1,780 deletions.
2 changes: 1 addition & 1 deletion docker/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN apt-get update -y \
mysql-client=5.7.41-0ubuntu0.18.04.1 \
libmysqlclient-dev=5.7.41-0ubuntu0.18.04.1 \
python3=3.6.7-1~18.04 \
python3-pip=9.0.1-2.3~ubuntu1.18.04.6 \
python3-pip=9.0.1-2.3~ubuntu1.18.04.8 \
python3-future=0.15.2-4ubuntu2 \
python3-pygit2=0.26.2-2 \
&& apt-get clean \
Expand Down
17 changes: 17 additions & 0 deletions voyages/apps/blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from django.template.response import TemplateResponse

from voyages.extratools import AdvancedEditor

from .models import Post
from .models import Tag
from .models import Institution
Expand Down Expand Up @@ -225,9 +227,24 @@ def news_migration (self, request):
actions = [make_published,make_draft,translate_to_new_languages,force_translation]


class TagAdminForm(forms.ModelForm):
"""
Form for editing HTML for FAQ answer
"""
intro = forms.CharField(widget=AdvancedEditor(
attrs={'class': 'tinymcetextarea'}))

class Meta:
fields = '__all__'
model = Tag

class TagAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug':('name',)}

form = TagAdminForm



class InstitutionAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug':('name',)}

Expand Down
20 changes: 20 additions & 0 deletions voyages/apps/blog/migrations/0002_tag_intro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2023-02-14 14:44
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blog', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='tag',
name='intro',
field=models.TextField(blank=True),
),
]
3 changes: 3 additions & 0 deletions voyages/apps/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def __str__(self):
class Tag(models.Model):
name = models.CharField(max_length=200,unique=True)
slug = models.SlugField(max_length=200, unique=True)

intro = models.TextField(blank=True)

class Meta:
ordering = ['name']

Expand Down
21 changes: 20 additions & 1 deletion voyages/apps/blog/templates/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,29 @@
{% endblock title %}
</div>
<div class="navbar-subtitle flex">

</div>
</div>

{% if intro %}
<div id="blog_intro" class="blog_intro container-new">
</div>
<script type="text/javascript">
const introHtml = `{{ intro|safe }}`
const parser = new DOMParser();
const doc = parser.parseFromString(introHtml, "text/html");
const langCode = "{{ LANGUAGE_CODE }}";
const filteredNodes = [...doc.body.children]
.filter(node => {
const lang = node.attributes.getNamedItem('lang')?.nodeValue
return !lang || lang === langCode;
});
const eIntro = document.getElementById('blog_intro');
for (const node of filteredNodes) {
eIntro.appendChild(node);
}
</script>
{% endif %}

<div class="container-new">

<div class="card-columns">
Expand Down
20 changes: 13 additions & 7 deletions voyages/apps/blog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,30 @@
from django import template
register = template.Library()

class PostList(generic.ListView):
class PostList(generic.ListView):
template_name = 'blog/index.html'
paginate_by = 10

base_query = Post.objects.select_related()

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['title_override'] = self.kwargs.get('title_override')
tag_slug = self.kwargs.get('tag')
if tag_slug:
tag = Tag.objects.get(slug=tag_slug)
if tag and tag.intro:
context['intro'] = tag.intro
return context

def get_queryset(self):
lang_code = self.request.LANGUAGE_CODE or "en"

q = self.__class__.base_query
if self.request.resolver_match.url_name == 'news':
return Post.objects.filter(status=PUBLISH_STATUS, language=lang_code, tags__slug__in=['news']).order_by('-created_on').order_by('-created_on')
elif self.kwargs.get('tag') is None:
return Post.objects.filter(status=PUBLISH_STATUS, language=lang_code).order_by('-created_on').exclude(tags__in = Tag.objects.filter(slug__in = ['author-profile','institution-profile']) )

return Post.objects.filter(status=PUBLISH_STATUS, language=lang_code, tags__slug__in=[self.kwargs['tag']]).order_by('-created_on')
return q.filter(status=PUBLISH_STATUS, language=lang_code, tags__slug__in=['news']).order_by('-created_on').order_by('-created_on')
if self.kwargs.get('tag') is None:
return q.filter(status=PUBLISH_STATUS, language=lang_code).order_by('-created_on').exclude(tags__in = Tag.objects.filter(slug__in = ['author-profile','institution-profile']) )
return q.filter(status=PUBLISH_STATUS, language=lang_code, tags__slug__in=[self.kwargs['tag']]).order_by('-created_on')



Expand Down
25 changes: 3 additions & 22 deletions voyages/apps/contribute/templates/contribute/review_origins.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h4>Contributed Language Groups</h4>
<span v-if="contribData.is_multilingual">{% trans "Multilingual" %}</span>
<ul>
<li v-for="cl in contribData.contributed_language_groups">
[[ cl.language_group_name ]] ([[ cl.modern_country_name ]])
[[ cl.language_group_name ]]
</li>
</ul>
<div v-if="contribData.prev_language_group_contributions.length > 0">
Expand All @@ -74,13 +74,9 @@ <h4>Contributed Language Groups</h4>
<h3>Propagation</h3>
<label for="propagatedName">{% trans "Propagated Name" %}:</label>
<input class="form-control" name="propagatedName" type="text" v-model="propagatedName" />
<label for="propagatedCountry">{% trans "Propagated Modern Country" %}:</label>
<label for="propagatedCountry">{% trans "Modern Country" %}:</label>
<select id="propagatedCountry" class="form-control" v-model="propagatedCountry">
<option value=""></option>
<option value="remove">{% trans "Delink Modern Country" %}</option>
<option v-if="contribData.contributed_language_groups" disabled>--- {% trans "User Contributed" %} ---</option>
<option v-if="contribCountries" v-for="pair in contribCountries" v-bind:value="pair[0]">[[ pair[1] ]]</option>
<option disabled>--- {% trans "Editorial Choices" %} ---</option>
<option v-for="country in modernCountryChoices" v-bind:value="country.pk">[[ country.name ]]</option>
</select>
<label for="propagatedLang">{% trans "Propagated Language Group" %}:</label>
Expand All @@ -105,7 +101,6 @@ <h3>Propagation</h3>
<th>{% trans "Embarkation" %}</th>
<th>{% trans "Name" %}</th>
<th>{% trans "Language Group" %}</th>
<th>{% trans "Country" %}</th>
<th>{% trans "Notes" %}</th>
</tr>
</thead>
Expand Down Expand Up @@ -255,14 +250,6 @@ <h4 class="modal-title">{% trans "Review Summary" %}</h4>
}
return data;
}
}, {
data: row => ({ pk: row.pk, country: row.modern_country__name }),
render: function(data, type) {
if (type === 'display') {
return `<input type="checkbox" checked="true" v-bind:disabled="!propagatedCountry" id="check_C${data.pk}" value="C${data.pk}"> <span id="cell_C${data.pk}" class="font-weight-light overwrite">${data.country}</span>`;
}
return data;
}
}, {
data: row => ({ pk: row.pk, notes: row.notes }),
render: function(data, type) {
Expand All @@ -276,7 +263,7 @@ <h4 class="modal-title">{% trans "Review Summary" %}</h4>
}
],
scrollY: '30vh',
paginate: contribData.propagation_candidates.length > 10,
paginate: false, // Use scrolling instead since all the data is loaded upfront anyway
info: false,
bFilter: false,
pageLength: 10,
Expand Down Expand Up @@ -319,19 +306,13 @@ <h4 class="modal-title">{% trans "Review Summary" %}</h4>
for (const candidate of contribData.propagation_candidates) {
const propName = $(`#check_N${candidate.pk}`).prop('checked');
const propLang = $(`#check_L${candidate.pk}`).prop('checked');
const propCountry = $(`#check_C${candidate.pk}`).prop('checked');
// Create an action (update or preserve for each propagation field).
actions.push(makeAction(propName, candidate, 'modern_name', vmodel.propagatedName));
actions.push(makeAction(
propLang && !!vmodel.propagatedLanguage,
candidate,
'language_group_id',
getSelectionId(vmodel.propagatedLanguage)));
actions.push(makeAction(
propCountry && !!vmodel.propagatedCountry,
candidate,
'modern_country_id',
getSelectionId(vmodel.propagatedCountry)));
const notes = $("#notes_" + candidate.pk).text();
if (!!notes || !!candidate.notes) {
actions.push(makeAction(true, candidate, 'notes', notes));
Expand Down
Loading

0 comments on commit 7da3908

Please sign in to comment.