diff options
author | luxagraf <sng@luxagraf.net> | 2019-02-15 21:07:59 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2019-02-15 21:07:59 -0600 |
commit | d0be352d2338108429969dbb31323925cf0adb47 (patch) | |
tree | 0700fd464a4096744121a1aecfac7471c0707839 | |
parent | 373bdaa5d058141abe45b355b3bc0b6abe2a057e (diff) |
fixed a bug in jrnl archives location data
-rw-r--r-- | app/jrnl/migrations/0027_entry_country_slug.py | 18 | ||||
-rw-r--r-- | app/jrnl/models.py | 3 | ||||
-rw-r--r-- | app/jrnl/views.py | 1 | ||||
-rw-r--r-- | app/utils/util.py | 98 | ||||
-rw-r--r-- | design/sass/_global.scss | 4 |
5 files changed, 76 insertions, 48 deletions
diff --git a/app/jrnl/migrations/0027_entry_country_slug.py b/app/jrnl/migrations/0027_entry_country_slug.py new file mode 100644 index 0000000..4560497 --- /dev/null +++ b/app/jrnl/migrations/0027_entry_country_slug.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.5 on 2019-02-15 21:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('jrnl', '0026_entry_country_name'), + ] + + operations = [ + migrations.AddField( + model_name='entry', + name='country_slug', + field=models.CharField(blank=True, max_length=200, null=True), + ), + ] diff --git a/app/jrnl/models.py b/app/jrnl/models.py index 5b7457a..6f6da1d 100644 --- a/app/jrnl/models.py +++ b/app/jrnl/models.py @@ -48,6 +48,7 @@ class Entry(models.Model): location_name = models.CharField(max_length=200, blank=True, null=True) state_name = models.CharField(max_length=200, blank=True, null=True) country_name = models.CharField(max_length=200, blank=True, null=True) + country_slug = models.CharField(max_length=200, blank=True, null=True) region_name = models.CharField(max_length=200, blank=True, null=True) PUB_STATUS = ( (0, 'Draft'), @@ -179,6 +180,8 @@ class Entry(models.Model): self.location_name = self.location.name self.state_name = self.location.state.name self.country_name = self.location.state.country.name + self.country_slug = self.location.state.country.slug + print(self.title) self.region_name = self.location.state.country.lux_region.name if created and not self.featured_image: self.featured_image = LuxImage.objects.latest() diff --git a/app/jrnl/views.py b/app/jrnl/views.py index 1a29898..d1c4159 100644 --- a/app/jrnl/views.py +++ b/app/jrnl/views.py @@ -30,7 +30,6 @@ class EntryCountryList(PaginatedListView): """ Return a list of Entries by Country in reverse chronological order """ - template_name = "archives/writing.html" def get_context_data(self, **kwargs): # Call the base implementation first to get a context diff --git a/app/utils/util.py b/app/utils/util.py index 6d20a54..1779baa 100644 --- a/app/utils/util.py +++ b/app/utils/util.py @@ -53,55 +53,59 @@ def extract_main_image(markdown): def parse_image(s): soup = BeautifulSoup(s.group(), "lxml") for img in soup.find_all('img'): - cl = img['class'] - if cl[0] == 'postpic' or cl[0] == 'postpicright': - s = str(img).replace('[[base_url]]', settings.IMAGES_URL) - return s - else: - try: - image_id = img['id'].split("image-")[1] - i = apps.get_model('photos', 'LuxImage').objects.get(pk=image_id) - caption = False - exif = False - cluster_class = None - is_cluster = False - extra = None - if cl[0] == 'cluster': - css_class = cl[0] - is_cluster = True - cluster_class = cl[1] - try: - if cl[2] == 'caption': + try: + cl = img['class'] + if cl[0] == 'postpic' or cl[0] == 'postpicright': + s = str(img).replace('[[base_url]]', settings.IMAGES_URL) + return s + else: + try: + image_id = img['id'].split("image-")[1] + i = apps.get_model('photos', 'LuxImage').objects.get(pk=image_id) + caption = False + exif = False + cluster_class = None + is_cluster = False + extra = None + if cl[0] == 'cluster': + css_class = cl[0] + is_cluster = True + cluster_class = cl[1] + try: + if cl[2] == 'caption': + caption = True + elif cl[2] == 'exif': + exif = True + else: + extra = cl[2] + + if len(cl) > 3: + if cl[3] == 'exif': + exif = True + except: + pass + elif cl[0] != 'cluster' and len(cl) > 1: + css_class = cl[0] + if cl[1] == 'caption': caption = True - elif cl[2] == 'exif': + if cl[1] == 'exif': exif = True - else: - extra = cl[2] - - if len(cl) > 3: - if cl[3] == 'exif': - exif = True - except: - pass - elif cl[0] != 'cluster' and len(cl) > 1: - css_class = cl[0] - if cl[1] == 'caption': - caption = True - if cl[1] == 'exif': - exif = True - elif cl[0] != 'cluster' and len(cl) > 2: - css_class = cl[0] - if cl[1] == 'caption': - caption = True - if cl[2] == 'exif': - exif = True - print('caption'+str(caption)) - else: - css_class = cl[0] - return render_to_string("lib/img_%s.html" % css_class, {'image': i, 'caption': caption, 'exif': exif, 'is_cluster': is_cluster, 'cluster_class': cluster_class, 'extra': extra}) - except KeyError: - ''' regular inline image, not a luximage ''' - return str(img) + elif cl[0] != 'cluster' and len(cl) > 2: + css_class = cl[0] + if cl[1] == 'caption': + caption = True + if cl[2] == 'exif': + exif = True + print('caption'+str(caption)) + else: + css_class = cl[0] + return render_to_string("lib/img_%s.html" % css_class, {'image': i, 'caption': caption, 'exif': exif, 'is_cluster': is_cluster, 'cluster_class': cluster_class, 'extra': extra}) + except KeyError: + ''' regular inline image, not a luximage ''' + return str(img) + except KeyError: + ''' regular inline image, not a luximage ''' + return str(img) def render_images(s): diff --git a/design/sass/_global.scss b/design/sass/_global.scss index bfbb50e..94a49da 100644 --- a/design/sass/_global.scss +++ b/design/sass/_global.scss @@ -67,6 +67,10 @@ object, embed, video { width: 100%; height: auto; } +audio { + max-width: 100%; + width: 100%; +} blockquote { @include fontsize(18); display: block; |