Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Félix Sipma committed Jul 5, 2016
2 parents 99a0830 + b76ebdb commit bea4d2e
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 366 deletions.
17 changes: 17 additions & 0 deletions cartoterra/templates/_account_bar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% load i18n %}
{% load staticfiles %}
{% load in_group %}
{% load account_tags %}
{% if request.user.is_authenticated %}
Expand All @@ -10,6 +11,22 @@
{% if user.is_staff %}
<li><a href="/admin/" class="tooltip-cartoterra" title="{% trans "Admin" %}"><span class="glyphicon glyphicon-cog"></span><span class="visible-xs-inline"> {% trans "Admin" %}</span></a></li>
{% endif %}

<li class="dropdown">
<a id="cartoterra-navbar-add-geodata" class="tooltip-cartoterra dropdown" data-toggle="dropdown" data-target="#" aria-haspopup="true" aria-expanded="false" title="{% trans "Add a geodata" %}">
<span class="glyphicon glyphicon-plus"></span>
<span class="caret"></span>
<span class="visible-xs-inline"> {% trans "Add a geodata" %}</span>
</a>

<ul class="dropdown-menu" aria-labelledby="cartoterra-navbar-add-geodata">
<li><a href="{% url "add_building" %}"><img src="{% static "img/building_icon_h25.png" %}" width="15" height="15" alt="{% trans "Add Building" %}" /> {% trans "Building" %}</a></li>
<li><a href="{% url "add_worksite" %}"><img src="{% static "img/worksite_icon_h25.png" %}" width="15" height="15" alt="{% trans "Add Worksite" %}" /> {% trans "Worksite" %}</a></li>
<li><a href="{% url "add_event" %}"><img src="{% static "img/event_icon_h25.png" %}" width="15" height="15" alt="{% trans "Add Event" %}" /> {% trans "Event" %}</a></li>
<li><a href="{% url "add_stakeholder" %}"><img src="{% static "img/stakeholder_icon_h25.png" %}" width="15" height="15" alt="{% trans "Add Stakeholder" %}" /> {% trans "Stakeholder" %}</a></li>
</ul>
</li>

<li class="divider"></li>
<li><a href="{% url "account_logout" %}" class="tooltip-cartoterra" title="{% trans "Log out" %}"><span class="glyphicon glyphicon-off"></span><span class="visible-xs-inline"> {% trans "Log out" %}</span></a></li>
{% else %}
Expand Down
48 changes: 0 additions & 48 deletions fabfile.py

This file was deleted.

35 changes: 1 addition & 34 deletions geodata/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.contrib.contenttypes.admin import GenericTabularInline
from imagewidget import AdminImageWidget
from hvad import admin as hvadadmin
from imagekit.admin import AdminThumbnail
from leaflet.admin import LeafletGeoAdmin
Expand All @@ -18,27 +17,9 @@
StakeholderResource


class EarthAdmin(admin.ModelAdmin):
"""Modified admin.ModelAdmin (include special AdminImageWidget for the
image field)."""
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'image':
kwargs['widget'] = AdminImageWidget
return db_field.formfield(**kwargs)
return super(EarthAdmin, self).formfield_for_dbfield(db_field,
**kwargs)


class EarthRoleAdmin(hvadadmin.TranslatableAdmin):
"""EarthRole administration interface."""
# list_display = ['name']
# list_filter = ['name']
# search_fields = ['name']

fieldsets = (
# ('Roles', {'fields': (('name', ))}),
# ('Techniques', {'fields': (('name', 'description', 'image', 'url'))})
)

admin.site.register(EarthRole, EarthRoleAdmin)

Expand All @@ -53,19 +34,13 @@ class EarthTechniqueAdmin(admin.ModelAdmin):
('Techniques', {'fields': (('name', 'description', 'url'))}),
)


admin.site.register(EarthTechnique, EarthTechniqueAdmin)


class EventTypeAdmin(hvadadmin.TranslatableAdmin):
"""EarthEventType administration interface."""
# list_display = ['ident_name']
# list_filter = ['ident_name']
# search_fields = ['name']

fieldsets = (
# ('Identification Name', {'fields': (('ident_name', ))}),
# ('Techniques', {'fields': (('name', 'description', 'image', 'url'))})
)

admin.site.register(EventType, EventTypeAdmin)

Expand All @@ -91,13 +66,6 @@ class GeoDataAbstractAdmin(LeafletGeoAdmin):
)
inlines = [ImageInline]

# Default GeoDjango OpenLayers map options
# scrollable = False
# map_width = 700
# map_height = 325
# if settings.OPENLAYERS:
# openlayers_url = settings.OPENLAYERS

class Meta:
"""Abstract class."""
abstract = True
Expand Down Expand Up @@ -218,7 +186,6 @@ class EarthGroupAdminForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(EarthGroupAdminForm, self).__init__(*args, **kwargs)
self.fields['description_markdown'].widget = AdminPagedownWidget()
#self.fields['image'].widget = AdminImageWidget()


class EarthGroupAdmin(admin.ModelAdmin):
Expand Down
93 changes: 20 additions & 73 deletions geodata/feeds.py
Original file line number Diff line number Diff line change
@@ -1,139 +1,86 @@
#from django.contrib.syndication.views import Feed
from django.contrib.syndication.views import Feed
from django.contrib.gis.feeds import GeoRSSFeed
from django.utils.translation import ugettext_lazy as _
#from django.contrib.gis.feeds import Feed
from django.conf import settings
from geodata.models import Building, Worksite, Event, Stakeholder, EarthGroup
import itertools


class BuildingFeed(Feed):
"""A feed presenting changes and additions on Building."""
title = settings.SITE_NAME + " building news."
link = "/"
description = _("Updates on changes and additions to buildings of " +
settings.SITE_NAME + ".")

class GeodataAbstractFeed(Feed):
feed_type = GeoRSSFeed

#def item_extra_kwargs(self, item):
# return {'geometry' : self.item_geometry(item)}

def item_geometry(self, item):
return item.geometry

def items(self):
return Building.objects.order_by('-pub_date')[:20]

def item_title(self, item):
return item.name

def item_description(self, item):
return item.description

def item_pubdate(self, item):
return item.pub_date

class WorksiteFeed(Feed):
"""A feed presenting changes and additions on Worksite."""
title = _(settings.SITE_NAME + " worksite news.")

class BuildingFeed(GeodataAbstractFeed):
"""A feed presenting changes and additions on Building."""
title = settings.SITE_NAME + " building news."
link = "/"
description = _("Updates on changes and additions to worksites of " +
description = _("Updates on changes and additions to buildings of " +
settings.SITE_NAME + ".")

feed_type = GeoRSSFeed
def items(self):
return Building.objects.order_by('-pub_date')[:20]

#def item_extra_kwargs(self, item):
# return {'geometry' : self.item_geometry(item)}

def item_geometry(self, item):
return item.geometry
class WorksiteFeed(GeodataAbstractFeed):
"""A feed presenting changes and additions on Worksite."""
title = _(settings.SITE_NAME + " worksite news.")
link = "/"
description = _("Updates on changes and additions to worksites of " +
settings.SITE_NAME + ".")

def items(self):
return Worksite.objects.order_by('-pub_date')[:20]

def item_title(self, item):
return item.name

def item_description(self, item):
return item.description


class EventFeed(Feed):
class EventFeed(GeodataAbstractFeed):
"""A feed presenting changes and additions on Event."""
title = _(settings.SITE_NAME + " event news.")
link = "/"
description = _("Updates on changes and additions to events of " +
settings.SITE_NAME + ".")

feed_type = GeoRSSFeed

#def item_extra_kwargs(self, item):
# return {'geometry' : self.item_geometry(item)}

def item_geometry(self, item):
return item.geometry

def items(self):
return Event.objects.order_by('-pub_date')[:20]

def item_title(self, item):
return item.name

def item_description(self, item):
return item.description


class StakeholderFeed(Feed):
class StakeholderFeed(GeodataAbstractFeed):
"""A feed presenting changes and additions on Stakeholder."""
title = _(settings.SITE_NAME + " stakeholder news.")
link = "/"
description = _("Updates on changes and additions to stakeholders of " +
settings.SITE_NAME + ".")

feed_type = GeoRSSFeed

#def item_extra_kwargs(self, item):
# return {'geometry' : self.item_geometry(item)}

def item_geometry(self, item):
return item.geometry

def items(self):
return Stakeholder.objects.order_by('-pub_date')[:20]

def item_title(self, item):
return item.name

def item_description(self, item):
return item.description


class GeodataFeed(Feed):
class GeodataFeed(GeodataAbstractFeed):
"""A feed presenting changes and additions on cartoterra."""
title = _(settings.SITE_NAME + " new entries.")
link = "/"
description = _("Updates on changes and additions to geodata of " +
settings.SITE_NAME + ".")

feed_type = GeoRSSFeed

def item_geometry(self, item):
return item.geometry

def items(self):
queryset = list(itertools.chain(
Building.objects.order_by('-pub_date')[:20],
Worksite.objects.order_by('-pub_date')[:20],
Event.objects.order_by('-pub_date')[:20],
Stakeholder.objects.order_by('-pub_date')[:20]
))
return sorted(queryset, key=lambda x:x.pub_date, reverse=True)[:20]

def item_title(self, item):
return item.name

def item_description(self, item):
return item.description
return sorted(queryset, key=lambda x: x.pub_date, reverse=True)[:20]


class EarthGroupFeed(Feed):
Expand Down
71 changes: 0 additions & 71 deletions geodata/imagewidget.py

This file was deleted.

Loading

0 comments on commit bea4d2e

Please sign in to comment.