gista / summer-cesta-snp

Web mapping application for 'Cesta SNP' project. Gista Open Summer 2011
http://opensummer.cestasnp.sk/
2 stars 1 forks source link

Create simple application to demonstrate working Django-Joomla connection #12

Closed imincik closed 13 years ago

imincik commented 13 years ago

Demonstrate connection of models POI (PostGIS) and model containg photo gallery in Joomla (jos_joomgallery)

matusvalo commented 13 years ago

Commited some code addressing this issue. Created two tables in PostGIS model (JosArticleId, JosPhotoId) to storing id numbers (ManyToMany relation is useless because of: https://docs.djangoproject.com/en/1.3/topics/db/multi-db/#cross-database-relations)

matusvalo commented 13 years ago

Sample code from shell:

from mapdata.models import Poi, JosPhotoId, JosArticleId, Area import datetime from josdata.models import JosJoomgallery, JosContent from django.contrib.gis.geos import Point a1 = Area(name = 'Nizke Tatry') a1.save()

p1 = Poi(name = 'p1', area = a1, type = 1, created_by = 'Matus Valo', created_at = datetime.date.today(), active = True, point = Point(30,20)) p1.save()

aid = JosArticleId(JosContent.objects.all()[0].id) aid.save() pid = JosPhotoId(JosJoomgallery.objects.all()[0].id) pid.save()

p1.jos_article_id.add(aid) p1.jos_photo_id.add(pid) p1.save()