Skip to content

Commit

Permalink
Merge c327915 into f7b4503
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Apr 15, 2021
2 parents f7b4503 + c327915 commit c00c477
Show file tree
Hide file tree
Showing 87 changed files with 2,479 additions and 782 deletions.
2 changes: 0 additions & 2 deletions rdmo/conditions/templates/conditions/conditions.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ <h1>{% trans 'Conditions' %}</h1>
</li>
</ul>
</div>

<div class="panel panel-default" ng-show="service.hideCondition(condition)"></div>
</div>

{% include 'conditions/conditions_modal_form_conditions.html' %}
Expand Down
8 changes: 2 additions & 6 deletions rdmo/core/serializers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from markdown import markdown as markdown_function

from django.contrib.auth.models import Group
from django.contrib.sites.models import Site
from django.utils.encoding import force_text

from rest_framework import serializers

from rdmo.core.utils import get_languages
from rdmo.core.utils import get_languages, markdown2html


class RecursiveField(serializers.Serializer):
Expand Down Expand Up @@ -36,7 +32,7 @@ def to_representation(self, instance):

for markdown_field in self.markdown_fields:
if markdown_field in response and response[markdown_field]:
response[markdown_field] = markdown_function(force_text(response[markdown_field]))
response[markdown_field] = markdown2html(response[markdown_field])

return response

Expand Down
9 changes: 9 additions & 0 deletions rdmo/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# rdmo modules
'rdmo',
'rdmo.core',
'rdmo.overlays',
'rdmo.accounts',
'rdmo.services',
'rdmo.domain',
Expand Down Expand Up @@ -203,6 +204,14 @@

USER_API = True

OVERLAYS = {
'projects': [
'create-project',
'projects-table',
'import-project'
]
}

EXPORT_FORMATS = (
('pdf', _('PDF')),
('rtf', _('Rich Text Format')),
Expand Down
16 changes: 10 additions & 6 deletions rdmo/core/static/core/css/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ code {
}
}

u {
cursor: help;
text-decoration: underline;
text-decoration-style: dashed;
}

table {
p {
margin-bottom: 5px;
Expand Down Expand Up @@ -213,12 +219,10 @@ form .yesno label {
}

@media (min-width: $screen-xs-max) {
[class^="col-"] formgroup {
.checkbox,
.radio {
margin-top: 32px;
margin-bottom: 11px;
}
.checkbox-padding .checkbox,
.radio-padding .radio {
margin-top: 32px;
margin-bottom: 11px;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion rdmo/core/static/core/html/formgroup_selectnumber.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<label class="control-label" for="id">{$ label $}</label>

<select class="form-control" id="{$ id $}" ng-model="model" by-number>
<option ng-show="optionsNull" value="null">---</option>
<option ng-show="optionsNull" value="">---</option>
<option value="{$ option.id $}"
ng-repeat="option in options | filter: optionsFilter">
{$ option[optionsLabel] $}
Expand Down
4 changes: 2 additions & 2 deletions rdmo/core/static/core/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ angular.module('core', ['ngResource'])
} else {

ngModel.$parsers.push(function(view_value) {
if (view_value === 'null') {
if (view_value === '') {
return null;
} else {
return parseInt(view_value, 10);
Expand All @@ -138,7 +138,7 @@ angular.module('core', ['ngResource'])

ngModel.$formatters.push(function(model_value) {
if (model_value === null) {
return 'null';
return '';
} else {
return '' + model_value;
}
Expand Down
6 changes: 6 additions & 0 deletions rdmo/core/templates/core/base_navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
{% include 'core/base_navigation_socialaccount.html' %}
{% endif %}

<li>
<a href="{% url 'reset_overlays' %}">
{% trans 'Reset tutorial overlays' %}
</a>
</li>

<li role="separator" class="divider"></li>

{% if settings.ACCOUNT or settings.SOCIALACCOUNT %}
Expand Down
16 changes: 10 additions & 6 deletions rdmo/core/templatetags/core_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from django.urls import resolve, reverse
from django.urls.resolvers import Resolver404
from django.utils import translation
from django.utils.encoding import force_text
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.translation import get_language, to_locale
from markdown import markdown as markdown_function

from rdmo import __version__
from rdmo.core.utils import markdown2html

register = template.Library()

Expand All @@ -29,7 +29,7 @@ def i18n_switcher():


@register.simple_tag()
def render_lang_template(template_name):
def render_lang_template(template_name, escape_html=False):
loc = to_locale(get_language())
lst = [
template_name + '_' + loc + '.html',
Expand All @@ -39,8 +39,12 @@ def render_lang_template(template_name):
]
for el in lst:
try:
t = get_template(el)
return t.render()
template = get_template(el)
html = template.render()
if escape_html:
return escape(html)
else:
return html
except TemplateDoesNotExist:
pass
return ''
Expand Down Expand Up @@ -155,7 +159,7 @@ def back_to_project_link(context):
@register.filter(is_safe=True)
@stringfilter
def markdown(value):
return mark_safe(markdown_function(force_text(value)))
return mark_safe(markdown2html(value))


@register.simple_tag
Expand Down
1 change: 1 addition & 0 deletions rdmo/core/urls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
path('domain/', include('rdmo.domain.urls')),
path('management/', include('rdmo.management.urls')),
path('options/', include('rdmo.options.urls')),
path('overlays/', include('rdmo.overlays.urls')),
path('projects/', include('rdmo.projects.urls')),
path('questions/', include('rdmo.questions.urls')),
path('services/', include('rdmo.services.urls')),
Expand Down
1 change: 1 addition & 0 deletions rdmo/core/urls/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
path('conditions/', include('rdmo.conditions.urls.v1')),
path('domain/', include('rdmo.domain.urls.v1')),
path('options/', include('rdmo.options.urls.v1')),
path('overlays/', include('rdmo.overlays.urls.v1')),
path('projects/', include('rdmo.projects.urls.v1')),
path('questions/', include('rdmo.questions.urls.v1')),
path('tasks/', include('rdmo.tasks.urls.v1')),
Expand Down
13 changes: 13 additions & 0 deletions rdmo/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
from django.conf import settings
from django.http import Http404, HttpResponse, HttpResponseBadRequest
from django.template.loader import get_template
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
from markdown import markdown

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -300,3 +302,14 @@ def human2bytes(string):
return number * 1024**4
elif unit == 'pib':
return number * 1024**5


def markdown2html(markdown_string):
# adoption of the normal markdown function which also converts
# `[<string>]{<title>}` to <u title="<title>"><string></u> to
# allow for underlined tooltips
html = markdown(force_text(markdown_string))
html = re.sub(r'\[(.*?)\]\{(.*?)\}',
r'<u data-toggle="tooltip" data-placement="bottom" data-html="true" title="\2">\1</u>',
html)
return html
4 changes: 2 additions & 2 deletions rdmo/domain/templates/domain/domain.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ <h1>{% trans 'Domain' %}</h1>

<script type="text/ng-template" id="nested_attribute.html">

<div class="panel panel-default">
<div class="panel panel-default" ng-hide="service.hideAttribute(attribute)">

<div class="panel-body" ng-hide="service.hideAttribute(attribute)">
<div class="panel-body">
<div class="pull-right">
{% include 'domain/domain_options.html' %}
</div>
Expand Down
13 changes: 11 additions & 2 deletions rdmo/options/static/options/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,20 @@ angular.module('options', ['core'])
};

service.hideOptionSet = function(item) {
var hide = false;

if (service.filter && item.key.indexOf(service.filter) < 0) {
return true;
hide = true;
}
if (service.uri_prefix && item.uri_prefix != service.uri_prefix) {
return true;
hide = true;
}

if (hide === true) {
// hide only if all options of this optionsset are hidden
return item.options.every(function(option) {
return service.hideOption(option) === true;
});
}
};

Expand Down
28 changes: 17 additions & 11 deletions rdmo/options/templates/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ <h1>{% trans 'Options' %}</h1>

<div ng-repeat="optionset in service.optionsets" ng-cloak>

<div class="panel panel-default">
<div class="panel-heading" ng-hide="service.hideOptionSet(optionset)">
<div class="panel panel-default" ng-hide="service.hideOptionSet(optionset)">
<div class="panel-heading">
<div class="pull-right">
<i class="fa fa-lock text-danger" ng-show="optionset.locked"></i>

Expand Down Expand Up @@ -131,20 +131,22 @@ <h1>{% trans 'Options' %}</h1>
ng-click="service.openDeleteModal('optionsets', optionset)">
</a>
</div>
<strong>{% trans 'Option set' %}</strong>
<code class="code-order">{$ optionset.order $}</code>
<code class="code-options">{$ optionset.uri $}</code>
<div>
<strong>{% trans 'Option set' %}</strong>
<code class="code-order">{$ optionset.order $}</code>
<code class="code-options" title="{% trans 'URI' %}">{$ optionset.uri $}</code>
</div>
</div>

<ul class="list-group" ng-show="optionset.provider">
<ul class="list-group" ng-if="optionset.provider">
<li class="list-group-item">
<strong>{% trans 'Provider' %}</strong>
<code class="code-options-provider">{$ optionset.provider.class_name $}</code>
<span>{$ optionset.provider.label $}</span>
</li>
</ul>

<ul class="list-group">
<ul class="list-group" ng-if="optionset.options">
<li class="list-group-item" ng-repeat="option in optionset.options"
ng-hide="service.hideOption(option)">

Expand Down Expand Up @@ -177,10 +179,14 @@ <h1>{% trans 'Options' %}</h1>
ng-click="service.openDeleteModal('options', option)">
</a>
</div>
<strong>{% trans 'Option' %}</strong>
<code class="code-order">{$ option.order $}</code>
<code class="code-options">{$ option.uri $}</code>
<span>{$ option.text $}</span>
<p>
<strong>{% trans 'Option' %}</strong>
<code class="code-order">{$ option.order $}</code>
<span>{$ option.text $}</span>
</p>
<div>
<code class="code-options" title="{% trans 'URI' %}">{$ option.uri $}</code>
</div>
</li>
</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions rdmo/overlays/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = 'rdmo.overlays.apps.OverlayConfig'
12 changes: 12 additions & 0 deletions rdmo/overlays/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.contrib import admin

from .models import Overlay


class OverlayAdmin(admin.ModelAdmin):
search_fields = ('user__username', 'url_name', 'current')
list_display = ('user', 'site', 'url_name', 'current')
list_filter = ('url_name', 'current')


admin.site.register(Overlay, OverlayAdmin)
7 changes: 7 additions & 0 deletions rdmo/overlays/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _


class OverlayConfig(AppConfig):
name = 'rdmo.overlays'
verbose_name = _('Overlays')
33 changes: 33 additions & 0 deletions rdmo/overlays/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 2.2.18 on 2021-03-22 15:47

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('sites', '0002_alter_domain_unique'),
]

operations = [
migrations.CreateModel(
name='Overlay',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('url_name', models.SlugField(help_text='The url_name for this overlay.', max_length=128, verbose_name='Url name')),
('current', models.SlugField(blank=True, help_text='The current state for this overlay.', max_length=128, verbose_name='Current')),
('site', models.ForeignKey(help_text='The site for this overlay.', null=True, on_delete=django.db.models.deletion.SET_NULL, to='sites.Site', verbose_name='Site')),
('user', models.ForeignKey(help_text='The user for this overlay.', on_delete=django.db.models.deletion.CASCADE, related_name='overlays', to=settings.AUTH_USER_MODEL, verbose_name='User')),
],
options={
'verbose_name': 'Overlay',
'verbose_name_plural': 'Overlays',
'ordering': ('user', 'url_name'),
},
),
]
Empty file.

0 comments on commit c00c477

Please sign in to comment.