Skip to content

Commit

Permalink
split example into two models, better default styles
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Oct 7, 2015
1 parent dddead9 commit 1289085
Show file tree
Hide file tree
Showing 31 changed files with 601 additions and 197 deletions.
6 changes: 3 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def start(project_name, destination):
want to do the following:
\b
chmod +x deploy.sh db/manage.py
sudo chown www-data media/
cd app; wq init
cd app
wq init
See https://wq.io/docs/setup for more tips on getting started with wq.
"""
Expand All @@ -32,5 +32,5 @@ def start(project_name, destination):
project_name,
destination,
template=template,
extensions=["py", "yml", "conf", "html", "sh", "js"],
extensions=["py", "yml", "conf", "html", "sh", "js", "css", "json"],
)
3 changes: 3 additions & 0 deletions django_project/app/css/project_name.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
@import url("lib/jquery.mobile.icons.css");
@import url("lib/jquery.mobile.structure.css");
@import url("lib/leaflet.css");
@import url("lib/leaflet.draw.css");
@import url("{{ project_name }}/main.css");
@import url("{{ project_name }}/responsive.css");
25 changes: 25 additions & 0 deletions django_project/app/css/project_name/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.error {
color: red;
clear: both;
}

.footer {
text-align: center;
font-size: 0.8em;
}
.footer, .footer a, .footer a:visited {
color: #999;
}

.map {
border: 1px solid #999;
}
.map.list-map {
height: 500px;
}
.map.detail-map {
height: 300px;
}
.map.edit-map {
height: 400px;
}
11 changes: 11 additions & 0 deletions django_project/app/css/project_name/responsive.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@media screen and (min-width: 60em) {
.ui-mobile [data-role="page"], .ui-page {
width: 80%;
max-width: 60em;
margin-left: auto;
margin-right: auto;
position: relative;
border-left: 1px solid #999;
border-right: 1px solid #999;
}
}
Binary file added django_project/app/images/empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 24 additions & 3 deletions django_project/app/js/project_name/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
define(['wq/app', 'wq/map', './config'],
function(app, map, config) {
define(['wq/app', 'wq/map', 'wq/photos',
'./config',
'leaflet.draw'],
function(app, map, photos, config) {

app.use(map);
app.use(photos);

config.presync = presync;
config.postsync = postsync;
app.init(config).then(function() {
map.init(config.map);
app.jqmInit();
app.prefetchAll();
});

// Sync UI
function presync() {
$('button.sync').html("Syncing...");
$('li a.ui-icon-minus, li a.ui-icon-alert')
.removeClass('ui-icon-minus')
.removeClass('ui-icon-alert')
.addClass('ui-icon-refresh');
}

function postsync(items) {
$('button.sync').html("Sync Now");
app.syncRefresh(items);
}

});
6 changes: 6 additions & 0 deletions django_project/app/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "{{ project_name }} Project",
"start_url": "index.html",
"display": "fullscreen"
}

4 changes: 4 additions & 0 deletions django_project/app/wq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ appcache:
css-ignore: "css/lib/images/icons-png/.*"
cache:
- js/lib/require.js
- css/lib/images/marker-icon.png
- css/lib/images/marker-icon-2x.png
- css/lib/images/marker-shadow.png
- images/empty.png
network:
- "*"
- "http://*"
Expand Down
1 change: 1 addition & 0 deletions django_project/conf/project_name.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Alias /media {{ project_directory }}/media/
Alias /{{ project_name }}.appcache {{ project_directory }}/htdocs/{{ project_name }}.appcache
Alias /favicon.ico {{ project_directory }}/htdocs/favicon.ico
Alias /manifest.json /var/www/trywq/htdocs/manifest.json
Alias /robots.txt {{ project_directory }}/htdocs/robots.txt

# Uncomment the following line to use a static front page
Expand Down
6 changes: 0 additions & 6 deletions django_project/db/exampleapp/admin.py

This file was deleted.

32 changes: 32 additions & 0 deletions django_project/db/exampleapp/maps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
place_map = {
'list': {'autoLayers': True},
'detail': {'autoLayers': True},
'edit': {
'layers': [{
'name': 'Place Location(s)',
'type': 'geojson',
'url': 'places/{% templatetag openvariable %}id{% templatetag closevariable %}/edit.geojson',
'geometryField': 'locations',

# Leaflet.draw options
'draw': {
'circle': False,
'marker': {},
'polygon': {},
'polyline': False,
'rectangle': {},
}
}]
}
}

index_map = {
'defaults': {
'layers': [{
'name': 'Places',
'type': 'geojson',
'url': 'places.geojson',
'popup': 'place',
}]
}
}
18 changes: 15 additions & 3 deletions django_project/db/exampleapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,27 @@ class Migration(migrations.Migration):

operations = [
migrations.CreateModel(
name='Example',
name='Observation',
fields=[
('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')),
('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)),
('date', models.DateField()),
('photo', models.ImageField(upload_to='')),
],
),
migrations.CreateModel(
name='Place',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)),
('name', models.CharField(max_length=255)),
('description', models.TextField()),
],
options={
'abstract': False,
},
bases=(models.Model,),
),
migrations.AddField(
model_name='observation',
name='place',
field=models.ForeignKey(to='exampleapp.Place'),
),
]
11 changes: 10 additions & 1 deletion django_project/db/exampleapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
from wq.db.patterns import models as patterns


class Example(patterns.IdentifiedModel):
class Place(patterns.IdentifiedLocatedModel):
name = models.CharField(max_length=255)
description = models.TextField()


class Observation(models.Model):
place = models.ForeignKey(Place)
date = models.DateField()
photo = models.ImageField()

def __str__(self):
return "%s on %s" % (self.place, self.date)
15 changes: 11 additions & 4 deletions django_project/db/exampleapp/rest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from wq.db import rest
from wq.db.patterns import rest as patterns
from .models import Example
from .models import Place, Observation
from .maps import place_map, index_map

rest.router.register_model(Observation)

rest.router.register_model(
Example,
serializer=patterns.IdentifiedModelSerializer
Place,
serializer=patterns.IdentifiedLocatedModelSerializer,
map=place_map
)
rest.router.add_page('index', {'url': '', 'map': True})

rest.router.add_page('index', {
'url': '',
'map': index_map
})
3 changes: 2 additions & 1 deletion django_project/db/project_name/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
'rest_framework',

'wq.db.patterns.identify',
'wq.db.patterns.locate',
'wq.db.rest',
'wq.db.rest.auth',

Expand Down Expand Up @@ -75,7 +76,7 @@

# wq: Social auth (see http://psa.matiasaguirre.net/docs/backends/)
AUTHENTICATION_BACKENDS = (
# 'social.backends.google.GoogleOpenId',
# 'social.backends.google.GoogleOpenId',
'django.contrib.auth.backends.ModelBackend',
)

Expand Down
50 changes: 0 additions & 50 deletions django_project/templates/example_detail.html

This file was deleted.

80 changes: 0 additions & 80 deletions django_project/templates/example_edit.html

This file was deleted.

Loading

0 comments on commit 1289085

Please sign in to comment.