Skip to content

Commit

Permalink
Merge pull request #1472 from makinacorpus/services
Browse files Browse the repository at this point in the history
Add services (fix #1409)
  • Loading branch information
Gaël UTARD committed Aug 7, 2015
2 parents 0d6fef3 + 26c7472 commit a13d7fe
Show file tree
Hide file tree
Showing 30 changed files with 971 additions and 64 deletions.
1 change: 1 addition & 0 deletions docs/authors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ Credits
* *Food* designed by Rémy Médard from the Noun Project
* *Climbing* designed by Eric Milet from the Noun Project
* *Box Office* designed by Alessio Damiano from the Noun Project
* *Steep Descent* designed by Sergey Patutin from the Noun Project
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ CHANGELOG
2.0.1.dev0
------------------

**New features**

* Services

**Bug fixes**

* Reload supervisor configuration after Geotrek upgrade
Expand Down
13 changes: 13 additions & 0 deletions geotrek/authent/fixtures/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@

["read_trek", "trekking", "trek"],
["read_poi", "trekking", "poi"],
["read_service", "trekking", "service"],

["add_report", "feedback", "report"],
["read_report", "feedback", "report"]
Expand All @@ -159,6 +160,10 @@
["change_poi", "trekking", "poi"],
["delete_poi", "trekking", "poi"],
["export_poi", "trekking", "poi"],
["add_service", "trekking", "service"],
["change_service", "trekking", "service"],
["delete_service", "trekking", "service"],
["export_service", "trekking", "service"],

["add_theme", "common", "theme"],
["change_theme", "common", "theme"],
Expand All @@ -185,6 +190,10 @@
["add_weblinkcategory", "trekking", "weblinkcategory"],
["change_weblinkcategory", "trekking", "weblinkcategory"],
["delete_weblinkcategory", "trekking", "weblinkcategory"],
["add_servicetype", "trekking", "servicetype"],
["change_servicetype", "trekking", "servicetype"],
["delete_servicetype", "trekking", "servicetype"],
["publish_servicetype", "trekking", "servicetype"],

["add_informationdesk", "tourism", "informationdesk"],
["change_informationdesk", "tourism", "informationdesk"],
Expand Down Expand Up @@ -224,6 +233,7 @@

["read_trek", "trekking", "trek"],
["read_poi", "trekking", "poi"],
["read_service", "trekking", "service"],

["add_report", "feedback", "report"],
["read_report", "feedback", "report"],
Expand Down Expand Up @@ -318,6 +328,7 @@

["read_trek", "trekking", "trek"],
["read_poi", "trekking", "poi"],
["read_service", "trekking", "service"],

["add_report", "feedback", "report"],
["read_report", "feedback", "report"]
Expand All @@ -338,6 +349,8 @@
["export_trek", "trekking", "trek"],
["read_poi", "trekking", "poi"],
["export_poi", "trekking", "poi"],
["read_service", "trekking", "service"],
["export_service", "trekking", "service"],

["read_touristicevent", "tourism", "touristicevent"],
["export_touristicevent", "tourism", "touristicevent"],
Expand Down
1 change: 1 addition & 0 deletions geotrek/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ def gettext_noop(s):

TREK_DAY_DURATION = 10 # Max duration to be done in one day
TREK_ICON_SIZE_POI = 18
TREK_ICON_SIZE_SERVICE = 18
TREK_ICON_SIZE_PARKING = 18
TREK_ICON_SIZE_INFORMATION_DESK = 18

Expand Down
Binary file added geotrek/static/images/service-16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geotrek/static/images/service-96.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geotrek/static/images/service.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions geotrek/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,10 @@ body.screamshot #altitudegraph {
#mainform .chosen-container-multi {
width: 220px !important;
}

.servicetype img {
width: 18px;
height: 18px;
margin-left: 4px;
cursor: hand;
}
12 changes: 11 additions & 1 deletion geotrek/trekking/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .models import (
POIType, TrekNetwork, Practice, Accessibility, Route, DifficultyLevel,
WebLink, WebLinkCategory, Trek,
WebLink, WebLinkCategory, Trek, ServiceType,
)


Expand Down Expand Up @@ -107,6 +107,15 @@ class WebLinkCategoryAdmin(TranslationAdmin):
search_fields = ('label', )


class ServiceTypeAdmin(TranslationAdmin):
list_display = ('name', 'pictogram_img', 'practices_display')
search_fields = ('name',)

def practices_display(self, obj):
return ', '.join([practice.name for practice in obj.practices.all()])
practices_display.short_description = _(u"Practices")


# Register previously defined modeladmins
trek_admin_to_register = [
(POIType, POITypeAdmin),
Expand All @@ -117,6 +126,7 @@ class WebLinkCategoryAdmin(TranslationAdmin):
(DifficultyLevel, DifficultyLevelAdmin),
(WebLink, WebLinkAdmin),
(WebLinkCategory, WebLinkCategoryAdmin),
(ServiceType, ServiceTypeAdmin),
]

for model, model_admin in trek_admin_to_register:
Expand Down
30 changes: 30 additions & 0 deletions geotrek/trekking/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ def _prepare(cls, create, **kwargs):
return trek


class TrekWithServicesFactory(TrekFactory):
@classmethod
def _prepare(cls, create, **kwargs):
trek = super(TrekWithServicesFactory, cls)._prepare(create, **kwargs)
path = trek.paths.all()[0]
service1 = ServiceFactory.create(no_path=True)
service1.add_path(path, start=0.5, end=0.5)
service1.type.practices.add(trek.practice)
service2 = ServiceFactory.create(no_path=True)
service2.add_path(path, start=0.4, end=0.4)
service2.type.practices.add(trek.practice)
if create:
trek.save()
return trek


class TrekRelationshipFactory(factory.Factory):
FACTORY_FOR = models.TrekRelationship

Expand All @@ -129,3 +145,17 @@ class POIFactory(PointTopologyFactory):
description = factory.Sequence(lambda n: u"<p>description %s</p>" % n)
type = factory.SubFactory(POITypeFactory)
published = True


class ServiceTypeFactory(factory.Factory):
FACTORY_FOR = models.ServiceType

name = factory.Sequence(lambda n: u"ServiceType %s" % n)
pictogram = dummy_filefield_as_sequence('pictogram %s')
published = True


class ServiceFactory(PointTopologyFactory):
FACTORY_FOR = models.Service

type = factory.SubFactory(ServiceTypeFactory)
8 changes: 7 additions & 1 deletion geotrek/trekking/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from mapentity.filters import MapEntityFilterSet
from geotrek.core.filters import TopologyFilter

from .models import Trek, POI
from .models import Trek, POI, Service


class TrekFilterSet(MapEntityFilterSet):
Expand All @@ -23,3 +23,9 @@ class POIFilterSet(MapEntityFilterSet):
class Meta:
model = POI
fields = ['published', 'type', 'trek', 'structure']


class ServiceFilterSet(MapEntityFilterSet):
class Meta:
model = Service
fields = ['type', 'structure']
38 changes: 38 additions & 0 deletions geotrek/trekking/fixtures/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,5 +396,43 @@
"label": "Information touristique",
"label_fr": "Information touristique"
}
},
{
"pk": 1,
"model": "trekking.servicetype",
"fields": {
"name_fr": "Eau potable",
"name": "Drinking water",
"review": false,
"pictogram": "upload/drinking_water.svg",
"practices": [
1,
2,
3,
4
],
"published": true,
"publication_date": null,
"name_en": "Drinking water"
}
},
{
"pk": 2,
"model": "trekking.servicetype",
"fields": {
"name_fr": "Descente pentue",
"name": "Steep descent",
"review": false,
"pictogram": "upload/steep_descent.svg",
"practices": [
1,
2,
3,
4
],
"published": true,
"publication_date": null,
"name_en": "Steep descent"
}
}
]
6 changes: 6 additions & 0 deletions geotrek/trekking/fixtures/upload/drinking_water.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions geotrek/trekking/fixtures/upload/steep_descent.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a13d7fe

Please sign in to comment.