...
 
Commits (3)
......@@ -48,6 +48,8 @@ urlpatterns = [
path('resources', views.journals, name='resources_home'),
path('community', views.empty, name='community_home'),
path('register', views.register),
path('<slug:slug>', views.section_home, name='section_home'),
path('about/<slug:slug>', views.page, name='about'),
......@@ -75,8 +77,6 @@ urlpatterns = [
path('resources/publications/search/ajax', views.reference_search_ajax, name='reference_search_ajax'),
path('tags/ajax', views.tag_ajax, name='tag_ajax'),
path('register', views.register),
path('admin/people', views.admin_people_list, name='admin_people_list'),
path('admin/members', views.admin_member_list, name='admin_member_list'),
path('admin/people/create', views.admin_people, name='admin_people_create'),
......
......@@ -467,8 +467,11 @@ def project_view(request, type, status, id):
context = { 'section': 'community', 'list': list, 'info': info, 'editlink': editlink}
return render(request, 'core/project.view.html', context)
def reference_search_ajax(request):
references = Reference.objects.filter(title__icontains=request.GET['term'],status='active').order_by('title')
def reference_search_ajax(request, active_only=False):
if active_only:
references = Reference.objects.filter(title__icontains=request.GET['term'],status='active').order_by('title')
else:
references = Reference.objects.filter(title__icontains=request.GET['term']).order_by('title')
list = []
for details in references:
d = {}
......
......@@ -208,12 +208,17 @@ class Information(TimestampedModel):
title = models.CharField(max_length=255)
content = HTMLField('Content')
space = models.ForeignKey(ReferenceSpace, on_delete=models.CASCADE)
references = models.ManyToManyField('core.Reference', blank=True)
references = models.ManyToManyField("core.Reference", blank=True)
topic = models.ForeignKey(Topic, on_delete=models.CASCADE)
type = models.ForeignKey(ReferenceSpaceType, on_delete=models.CASCADE, null=True, blank=True)
def __str__(self):
return self.title
class InformationForm(ModelForm):
class Meta:
model = Information
fields = ['title', 'content']
class GraphType(models.Model):
title = models.CharField(max_length=255)
slug = models.CharField(max_length=255)
......
......@@ -37,6 +37,8 @@ urlpatterns = [
path('<slug:city>/datasets/<int:id>/delete', views.delete_dataset, name='delete_dataset'),
path('<slug:city>/datasets/<int:dataset>/graph/<int:id>', views.graph, name='graph'),
path('<slug:city>/datasets/<int:id>/<slug:slug>', views.dataset, name='dataset_slice'),
path('<slug:city>/information', views.information_form, name='information_form'),
path('<slug:city>/information/<int:id>', views.information_form, name='information_form'),
# Uploading data
path('<slug:city>/upload', views.upload, name='upload'),
......
......@@ -2,7 +2,7 @@ from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404, redirect
from django.urls import reverse
from .models import Topic, DatasetType, ReferenceSpace, ReferenceSpaceType, Feature, ReferenceSpaceCSV, ReferenceSpaceLocation, ReferenceSpaceFeature, ReferenceSpaceForm, ReferenceSpaceLocationForm, DQI, DQIRating, Information, GraphType, DatasetType, DatasetTypeForm, DatasetTypeStructure
from .models import Topic, DatasetType, ReferenceSpace, ReferenceSpaceType, Feature, ReferenceSpaceCSV, ReferenceSpaceLocation, ReferenceSpaceFeature, ReferenceSpaceForm, ReferenceSpaceLocationForm, DQI, DQIRating, Information, GraphType, DatasetType, DatasetTypeForm, DatasetTypeStructure, InformationForm
from django.contrib.auth.decorators import login_required
from django.contrib.admin.views.decorators import staff_member_required
from django.template.defaultfilters import slugify
......@@ -104,7 +104,7 @@ def overview(request, city, slug):
def datasets(request, city):
info = get_object_or_404(ReferenceSpace, slug=city)
datasets = Dataset.objects.filter(primary_space=info)
datasets = Dataset.objects.filter(primary_space=info, deleted=False)
topics = Topic.objects.exclude(position=0).filter(parent__isnull=True)
context = { 'section': 'cities', 'menu': 'resources', 'page': 'datasets', 'info': info, 'datasets': datasets, 'topics': topics }
return render(request, 'multiplicity/datasets.html', context)
......@@ -225,10 +225,12 @@ def topicmap(request, city, theme, topic):
@login_required
def upload_flow(request, city, type='flows'):
info = get_object_or_404(ReferenceSpace, slug=city)
topics = Topic.objects.exclude(position=0).filter(parent__isnull=True)
types = False
if type == 'flows':
types = DatasetTypeStructure.objects.filter(pk__in=[8,9,10,11,6])
list = DatasetType.objects.filter(type=type)
addlink = '/admin/multiplicity/datasettype/add/'
context = { 'section': 'cities', 'menu': 'upload', 'info': info, 'list': list, 'topics': topics, 'addlink': addlink, 'type': type}
context = { 'section': 'cities', 'menu': 'upload', 'info': info, 'list': list, 'types': types, 'addlink': addlink, 'type': type}
return render(request, 'multiplicity/upload/index.flow.html', context)
@login_required
......@@ -984,6 +986,33 @@ def materials(request):
# Admin
@login_required
def information_form(request, city, id=False):
info = get_object_or_404(ReferenceSpace, slug=city)
if id:
information = get_object_or_404(Information, pk=id)
form = InformationForm(instance=info)
else:
information = False
form = InformationForm()
saved = False
if request.method == 'POST':
if not id:
form = InformationForm(request.POST, request.FILES)
else:
form = InformationForm(request.POST, request.FILES, instance=information)
if form.is_valid():
information = form.save()
saved = True
messages.success(request, 'Information was saved.')
return redirect(reverse('multiplicity:admin_datasettypes'))
else:
messages.warning(request, 'We could not save your form, please correct the errors')
context = { 'section': 'cities', 'info': info, 'form': form, 'type': type }
return render(request, 'multiplicity/information.form.html', context)
@staff_member_required
def admin_referencespaces(request, type):
type = ReferenceSpaceType.objects.get(slug=type)
......
{% extends 'multiplicity/base.html' %}
{% load bootstrap3 %}
{% load static %}
{% block title %}Dataset type{% endblock %}
{% block container %}stretch-bg-head{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-12">
<div class="panel panel-body">
<div class="panel-heading">
<h3>Dataset type</h3>
</div>
<div class="panel-body" style="margin-top:30px">
<form method="post" class="form form-horizontal" enctype="multipart/form-data">
{% bootstrap_form form layout='horizontal' %}
{% buttons %}
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-success">
Save
</button>
</div>
{% endbuttons %}
{% csrf_token %}
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block head %}
{% endblock %}
{% block sidebar %}
{% include 'multiplicity/sidebar.default.html' %}
{% endblock %}
{% block pagehead %}
{% endblock %}
{% block footer %}
{% endblock %}
......@@ -46,7 +46,10 @@
</div>
</td>
{% else %}
<td><a href="{% url 'multiplicity:upload_flow_file' info.slug item.id %}"><i class="fa fa-upload"></i> Upload</a></td>
<td>
<a href="{% url 'multiplicity:upload_flow_file' info.slug item.id %}"><i class="fa fa-upload"></i> Data</a>
<a class="hide" href="{% url 'multiplicity:information_form' info.slug %}"><i class="fa fa-upload"></i> Information</a>
</td>
{% endif %}
</tr>
<tr class="extra-info">
......
......@@ -44,7 +44,7 @@
<ul class="collapse {% if flow.parent.slug == "material-flows" and menu == "overview" %}in{% endif %}">
<li{% if slug == "external" %} class="active"{% endif %}><a href="{% url 'multiplicity:overview_flows' info.slug 'external' %}">External flows</a></li>
<li{% if slug == "internal" %} class="active"{% endif %}><a href="{% url 'multiplicity:overview_flows' info.slug 'internal' %}""">Internal flows flows</a></li>
<li{% if slug == "internal" %} class="active"{% endif %}><a href="{% url 'multiplicity:overview_flows' info.slug 'internal' %}""">Internal flows</a></li>
</ul>
</li>
......
......@@ -13,21 +13,23 @@
<div class="panel-body">
<div class="row">
<div class="col-sm-3">
<p><strong>Topic:</strong></p>
<ul class="nav nav-list topics">
{% for details in topics %}
<li><a href="#" data-topic="{{ details.id }}">{{ details.name }}</a></li>
{% endfor %}
</ul>
</div>
{% if type == 'flows' %}
<div class="col-sm-3">
<p><strong>Topic:</strong></p>
<ul class="nav nav-list types">
{% for details in types %}
<li><a href="#" data-type="{{ details.id }}">{{ details.name }}</a></li>
{% endfor %}
</ul>
</div>
{% endif %}
<div class="col-sm-9 datasets">
<p><strong>Datasets:</strong></p>
<ul class="nav nav-list">
{% for details in list %}
<li class="{% if details.topic %}topic-{{ details.topic.id }}{% else %}topic-all{% endif %}"><a href="{% url 'multiplicity:upload_flow_file' info.slug details.id %}">{{ details.name }}</a></li>
<li class="type-{{ details.category.id }}"><a href="{% url 'multiplicity:upload_flow_file' info.slug details.id %}">{{ details.name }}</a></li>
{% endfor %}
</ul>
......@@ -41,7 +43,7 @@
{% block head %}
<style type="text/css">
.datasets p,.datasets li{display:none}
{% if type == 'flows' %}.datasets p,.datasets li{display:none}{% endif %}
.nav > li > a:focus, .nav > li > a:hover{background:#fff}
#page-content .nav-list a:not(.btn):not(.list-group-item):hover{text-decoration:none}
</style>
......@@ -74,13 +76,12 @@
<script type="text/javascript">
$(function(){
$(".topics a").click(function(e){
$(".types a").click(function(e){
e.preventDefault();
$(".datasets p").show();
$(".datasets li").hide();
var topic = $(this).data("topic");
$(".datasets li.topic-"+topic).show('fast');
$(".datasets li.topic-all").show('fast');
var type = $(this).data("type");
$(".datasets li.type-"+type).show('fast');
});
});
</script>
......