diff options
author | luxagraf <sng@luxagraf.net> | 2018-04-05 09:30:44 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2018-04-05 09:30:44 -0400 |
commit | a26ad92062c8d1ab13727a2a4f4293d17d09808c (patch) | |
tree | f40e6d729fab874fb80376f32be9da84d13120d5 /app | |
parent | 2d440f0c309f49803ec95c46d9f586a7305780cd (diff) |
added image to links for screencaptures
Diffstat (limited to 'app')
-rw-r--r-- | app/links/admin.py | 6 | ||||
-rw-r--r-- | app/links/migrations/0004_link_image.py | 19 | ||||
-rw-r--r-- | app/links/models.py | 5 | ||||
-rw-r--r-- | app/people/migrations/0001_initial.py | 4 | ||||
-rw-r--r-- | app/sightings/build.py | 9 |
5 files changed, 32 insertions, 11 deletions
diff --git a/app/links/admin.py b/app/links/admin.py index 1811b3f..3bec927 100644 --- a/app/links/admin.py +++ b/app/links/admin.py @@ -9,6 +9,8 @@ from utils.widgets import TagListFilter from .models import Link from .forms import LinkForm + +@admin.register(Link) class LinkAdmin(admin.ModelAdmin): form = LinkForm list_display = ('title', 'admin_link', 'pub_date', 'status') @@ -26,7 +28,7 @@ class LinkAdmin(admin.ModelAdmin): ('Details', { 'fields': ( 'pub_date', - 'tags', + ('tags', 'image'), 'status' ), 'classes': 'collapse' @@ -35,5 +37,3 @@ class LinkAdmin(admin.ModelAdmin): class Media: js = ('next-prev-links.js',) - -admin.site.register(Link, LinkAdmin) diff --git a/app/links/migrations/0004_link_image.py b/app/links/migrations/0004_link_image.py new file mode 100644 index 0000000..9fe6ab1 --- /dev/null +++ b/app/links/migrations/0004_link_image.py @@ -0,0 +1,19 @@ +# Generated by Django 2.0.1 on 2018-04-05 09:06 + +from django.db import migrations, models +import links.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('links', '0003_auto_20171214_2239'), + ] + + operations = [ + migrations.AddField( + model_name='link', + name='image', + field=models.FileField(blank=True, null=True, upload_to=links.models.get_upload_path), + ), + ] diff --git a/app/links/models.py b/app/links/models.py index cdbe680..8ebc962 100644 --- a/app/links/models.py +++ b/app/links/models.py @@ -35,6 +35,10 @@ def email_link(link): msg.send() +def get_upload_path(self, filename): + return "images/links/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) + + class Link(models.Model): title = models.CharField(max_length=400) url = models.CharField(max_length=400) @@ -47,6 +51,7 @@ class Link(models.Model): ) status = models.IntegerField(choices=PUB_STATUS, default=0) tags = TaggableManager(blank=True) + image = models.FileField(blank=True, null=True, upload_to=get_upload_path) class Meta: ordering = ['-pub_date'] diff --git a/app/people/migrations/0001_initial.py b/app/people/migrations/0001_initial.py index 9174f3f..6f21bea 100644 --- a/app/people/migrations/0001_initial.py +++ b/app/people/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.0.1 on 2018-03-07 10:27 +# Generated by Django 2.0.1 on 2018-04-05 09:06 from django.db import migrations, models import django.db.models.deletion @@ -28,7 +28,7 @@ class Migration(migrations.Migration): ('postal_code', models.CharField(blank=True, max_length=20, null=True)), ('country', models.CharField(max_length=200, null=True)), ('phone', models.CharField(blank=True, max_length=22, null=True)), - ('slug', models.CharField(max_length=50)), + ('slug', models.CharField(blank=True, max_length=50)), ('body_markdown', models.TextField(blank=True, null=True)), ('body_html', models.TextField(blank=True, null=True)), ('next_contact_date', models.DateField(blank=True, null=True)), diff --git a/app/sightings/build.py b/app/sightings/build.py index 5321eff..14b363c 100644 --- a/app/sightings/build.py +++ b/app/sightings/build.py @@ -1,30 +1,27 @@ -import os from django.urls import reverse from builder.base import BuildNew -from django.contrib.auth.models import User -from .models import Sighting class BuildSightings(BuildNew): def build(self): - users = User.objects.all() self.build_detail_view() self.build_list_view( base_path=reverse("sightings:list"), paginate_by=24 ) - #for user in users: + # for user in users: # if Sighting.objects.filter(seen_by=user): # self.build_list_view( # base_path=reverse("sightings:list_by_person", kwargs={'user': user, 'page':1}), # paginate_by=24 # ) - #print("building sightings") + # print("building sightings") def get_model_queryset(self): return self.model.objects.all() + def builder(): j = BuildSightings("sightings", "sighting") j.build() |