summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/sightings/admin.py5
-rw-r--r--app/sightings/migrations/0003_auto_20180209_1037.py39
-rw-r--r--app/sightings/models.py14
3 files changed, 53 insertions, 5 deletions
diff --git a/app/sightings/admin.py b/app/sightings/admin.py
index 433d465..f2a8e8e 100644
--- a/app/sightings/admin.py
+++ b/app/sightings/admin.py
@@ -28,12 +28,15 @@ class APAdmin(admin.ModelAdmin):
list_display = ('pk', 'common_name', 'scientific_name', 'kind', 'code', 'apclass')
list_filter = ('apclass__kind','apclass')
search_fields = ['common_name', 'scientific_name']
+
+ class Media:
+ js = ('next-prev-links.js', 'image-preview.js')
@admin.register(Sighting)
class SightingAdmin(OSMGeoAdmin):
form = GalleryFormPlus
- list_filter = ('seen_by',('location', admin.RelatedOnlyFieldListFilter),)
+ list_filter = (('location', admin.RelatedOnlyFieldListFilter),)
list_display = ('ap', 'location')
# options for OSM map Using custom ESRI topo map
lat, lon = get_latlon()
diff --git a/app/sightings/migrations/0003_auto_20180209_1037.py b/app/sightings/migrations/0003_auto_20180209_1037.py
new file mode 100644
index 0000000..804bc47
--- /dev/null
+++ b/app/sightings/migrations/0003_auto_20180209_1037.py
@@ -0,0 +1,39 @@
+# Generated by Django 2.0.1 on 2018-02-09 10:37
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('sightings', '0002_auto_20180205_1430'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='ap',
+ name='image',
+ ),
+ migrations.RemoveField(
+ model_name='ap',
+ name='image_credit',
+ ),
+ migrations.RemoveField(
+ model_name='sighting',
+ name='images',
+ ),
+ migrations.RemoveField(
+ model_name='sighting',
+ name='seen_by',
+ ),
+ migrations.AddField(
+ model_name='ap',
+ name='body_html',
+ field=models.TextField(blank=True, null=True),
+ ),
+ migrations.AddField(
+ model_name='ap',
+ name='body_markdown',
+ field=models.TextField(blank=True, null=True),
+ ),
+ ]
diff --git a/app/sightings/models.py b/app/sightings/models.py
index 792c52b..80b9ba9 100644
--- a/app/sightings/models.py
+++ b/app/sightings/models.py
@@ -54,8 +54,10 @@ class AP(models.Model):
scientific_name = models.CharField(max_length=200)
code = models.IntegerField(choices=ABA_CODES, default=0)
apclass = models.ForeignKey(APClass, on_delete=models.CASCADE)
- image = models.FileField(upload_to=get_upload_path, null=True, blank=True, help_text="width of high res is 1360px")
- image_credit = models.CharField(max_length=200, blank=True, null=True)
+ body_html = models.TextField(null=True, blank=True)
+ body_markdown = models.TextField(null=True, blank=True)
+ #image = models.FileField(upload_to=get_upload_path, null=True, blank=True, help_text="width of high res is 1360px")
+ #image_credit = models.CharField(max_length=200, blank=True, null=True)
def __str__(self):
return self.common_name
@@ -75,6 +77,9 @@ class AP(models.Model):
ordering = ["common_name", ]
def save(self, *args, **kwargs):
+ if self.pk:
+ md = render_images(self.body_markdown)
+ self.body_html = markdown_to_html(md)
self.slug = slugify(self.common_name[:50])
super(AP, self).save(*args, **kwargs)
@@ -84,8 +89,8 @@ class Sighting(models.Model):
point = models.PointField(blank=True)
location = models.ForeignKey(Location, on_delete=models.CASCADE, blank=True)
pub_date = models.DateTimeField('Date', default=timezone.now)
- seen_by = models.ManyToManyField(User)
- images = models.ManyToManyField(LuxImage, blank=True)
+ #seen_by = models.ManyToManyField(User)
+ #images = models.ManyToManyField(LuxImage, blank=True)
#audio = models.ManyToManyField(BirdAudio, blank=True)
class Meta:
@@ -150,6 +155,7 @@ class Sighting(models.Model):
raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL))
super(Sighting, self).save()
+
"""
Migration from Birds to abstract:
apclass = OLDAPClass.objects.all()