Apply pyupgrade --py36-plus (but skip f-strings as we're on Python 3.5)
				
					
				
			This commit is contained in:
		
							parent
							
								
									5900f347c4
								
							
						
					
					
						commit
						9e39d7eadc
					
				
					 37 changed files with 56 additions and 107 deletions
				
			
		|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| import hashlib | import hashlib | ||||||
| 
 | 
 | ||||||
| from django.conf import settings | from django.conf import settings | ||||||
|  | @ -8,7 +7,7 @@ from django.conf import settings | ||||||
| from django.shortcuts import render as render_template_with_context | from django.shortcuts import render as render_template_with_context | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ParameterValidator(object): | class ParameterValidator: | ||||||
|     def __init__(self, given_hash_or_params, params_hash_key=None): |     def __init__(self, given_hash_or_params, params_hash_key=None): | ||||||
|         if params_hash_key is None: |         if params_hash_key is None: | ||||||
|             self.given_hash = given_hash_or_params |             self.given_hash = given_hash_or_params | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 |  | ||||||
| from django.apps import AppConfig | from django.apps import AppConfig | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.10.7 on 2021-11-30 00:24 | # Generated by Django 1.10.7 on 2021-11-30 00:24 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.11.29 on 2021-12-06 22:37 | # Generated by Django 1.11.29 on 2021-12-06 22:37 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| import datetime | import datetime | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.11.29 on 2021-12-06 22:49 | # Generated by Django 1.11.29 on 2021-12-06 22:49 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
| import uuid | import uuid | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.11.29 on 2023-01-27 06:02 | # Generated by Django 1.11.29 on 2023-01-27 06:02 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| import conservancy.apps.assignment.models | import conservancy.apps.assignment.models | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 |  | ||||||
| import uuid | import uuid | ||||||
| 
 | 
 | ||||||
| from django.core.validators import URLValidator, ValidationError | from django.core.validators import URLValidator, ValidationError | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| import textwrap | import textwrap | ||||||
| 
 | 
 | ||||||
| TERMS = textwrap.dedent("""\ | TERMS = textwrap.dedent("""\ | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| from django.db import models | from django.db import models | ||||||
| from django.conf import settings | from django.conf import settings | ||||||
| from conservancy import bsoup | from conservancy import bsoup | ||||||
|  | @ -11,14 +10,14 @@ class EntryTag(models.Model): | ||||||
|     label = models.CharField(max_length=100) |     label = models.CharField(max_length=100) | ||||||
|     slug = models.SlugField() |     slug = models.SlugField() | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         db_table = 'techblog_entrytag' # legacy |         db_table = 'techblog_entrytag' # legacy | ||||||
| 
 | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return self.label |         return self.label | ||||||
| 
 | 
 | ||||||
|     def get_absolute_url(self): |     def get_absolute_url(self): | ||||||
|         return u"/blog/?tag=%s" % self.slug |         return "/blog/?tag=%s" % self.slug | ||||||
| 
 | 
 | ||||||
| class Entry(models.Model, bsoup.SoupModelMixin): | class Entry(models.Model, bsoup.SoupModelMixin): | ||||||
|     """Blog entry""" |     """Blog entry""" | ||||||
|  | @ -34,7 +33,7 @@ class Entry(models.Model, bsoup.SoupModelMixin): | ||||||
|     date_created = models.DateTimeField(auto_now_add=True) |     date_created = models.DateTimeField(auto_now_add=True) | ||||||
|     date_last_modified = models.DateTimeField(auto_now=True) |     date_last_modified = models.DateTimeField(auto_now=True) | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         db_table = 'techblog_entries' # legacy |         db_table = 'techblog_entries' # legacy | ||||||
|         verbose_name_plural = 'entries' |         verbose_name_plural = 'entries' | ||||||
|         ordering = ('-pub_date',) |         ordering = ('-pub_date',) | ||||||
|  | @ -46,7 +45,7 @@ class Entry(models.Model, bsoup.SoupModelMixin): | ||||||
|         return self.headline |         return self.headline | ||||||
| 
 | 
 | ||||||
|     def get_absolute_url(self): |     def get_absolute_url(self): | ||||||
|         return (u"/blog/%s/%s/" |         return ("/blog/%s/%s/" | ||||||
|                 % (self.pub_date.strftime("%Y/%b/%d").lower(), |                 % (self.pub_date.strftime("%Y/%b/%d").lower(), | ||||||
|                    self.slug)) |                    self.slug)) | ||||||
| 
 | 
 | ||||||
|  | @ -58,7 +57,7 @@ class Entry(models.Model, bsoup.SoupModelMixin): | ||||||
|     # http://blog.foozia.com/blog/2007/apr/21/ping-technorati-your-django-blog-using-xml-rpc/ |     # http://blog.foozia.com/blog/2007/apr/21/ping-technorati-your-django-blog-using-xml-rpc/ | ||||||
|     def save(self): |     def save(self): | ||||||
|         if settings.CONSERVANCY_DEVEL or True: # "or True" means it is disabled always |         if settings.CONSERVANCY_DEVEL or True: # "or True" means it is disabled always | ||||||
|             super(Entry, self).save() |             super().save() | ||||||
|             return |             return | ||||||
| 
 | 
 | ||||||
|         blog_name = 'Software Freedom Conservancy Blog' |         blog_name = 'Software Freedom Conservancy Blog' | ||||||
|  | @ -77,4 +76,4 @@ class Entry(models.Model, bsoup.SoupModelMixin): | ||||||
|         reply = j.weblogUpdates.ping(blog_name, blog_url, post_url) |         reply = j.weblogUpdates.ping(blog_name, blog_url, post_url) | ||||||
| 
 | 
 | ||||||
|         # Call any superclass's method |         # Call any superclass's method | ||||||
|         super(Entry, self).save() |         super().save() | ||||||
|  |  | ||||||
|  | @ -96,7 +96,7 @@ def query(request): | ||||||
| 
 | 
 | ||||||
|         query_string = d.urlencode() |         query_string = d.urlencode() | ||||||
| 
 | 
 | ||||||
|         return relative_redirect(request, '%s%s%s' % (base_url, '?' if query_string else '', query_string)) |         return relative_redirect(request, '{}{}{}'.format(base_url, '?' if query_string else '', query_string)) | ||||||
| 
 | 
 | ||||||
|     else: |     else: | ||||||
|         authors = sorted(Person.objects.filter(currently_employed=True, |         authors = sorted(Person.objects.filter(currently_employed=True, | ||||||
|  | @ -113,7 +113,7 @@ def relative_redirect(request, path): | ||||||
|     if settings.FORCE_CANONICAL_HOSTNAME: |     if settings.FORCE_CANONICAL_HOSTNAME: | ||||||
|         host = settings.FORCE_CANONICAL_HOSTNAME |         host = settings.FORCE_CANONICAL_HOSTNAME | ||||||
| 
 | 
 | ||||||
|     url = "%s://%s%s" % (request.is_secure() and 'https' or 'http', host, path) |     url = "{}://{}{}".format(request.is_secure() and 'https' or 'http', host, path) | ||||||
|     return http.HttpResponseRedirect(url) |     return http.HttpResponseRedirect(url) | ||||||
| 
 | 
 | ||||||
| class BlogYearArchiveView(YearArchiveView): | class BlogYearArchiveView(YearArchiveView): | ||||||
|  | @ -122,7 +122,7 @@ class BlogYearArchiveView(YearArchiveView): | ||||||
|     extra_context = {} |     extra_context = {} | ||||||
|      |      | ||||||
|     def get_context_data(self, **kwargs): |     def get_context_data(self, **kwargs): | ||||||
|         context = super(BlogYearArchiveView, self).get_context_data(**kwargs) |         context = super().get_context_data(**kwargs) | ||||||
|         context.update(self.extra_context) |         context.update(self.extra_context) | ||||||
|         return context |         return context | ||||||
| 
 | 
 | ||||||
|  | @ -131,7 +131,7 @@ class BlogMonthArchiveView(MonthArchiveView): | ||||||
|     extra_context = {} |     extra_context = {} | ||||||
|      |      | ||||||
|     def get_context_data(self, **kwargs): |     def get_context_data(self, **kwargs): | ||||||
|         context = super(BlogMonthArchiveView, self).get_context_data(**kwargs) |         context = super().get_context_data(**kwargs) | ||||||
|         context.update(self.extra_context) |         context.update(self.extra_context) | ||||||
|         return context |         return context | ||||||
| 
 | 
 | ||||||
|  | @ -140,7 +140,7 @@ class BlogDayArchiveView(DayArchiveView): | ||||||
|     extra_context = {} |     extra_context = {} | ||||||
|      |      | ||||||
|     def get_context_data(self, **kwargs): |     def get_context_data(self, **kwargs): | ||||||
|         context = super(BlogDayArchiveView, self).get_context_data(**kwargs) |         context = super().get_context_data(**kwargs) | ||||||
|         context.update(self.extra_context) |         context.update(self.extra_context) | ||||||
|         return context |         return context | ||||||
| 
 | 
 | ||||||
|  | @ -149,6 +149,6 @@ class BlogDateDetailView(DateDetailView): | ||||||
|     extra_context = {} |     extra_context = {} | ||||||
|      |      | ||||||
|     def get_context_data(self, **kwargs): |     def get_context_data(self, **kwargs): | ||||||
|         context = super(BlogDateDetailView, self).get_context_data(**kwargs) |         context = super().get_context_data(**kwargs) | ||||||
|         context.update(self.extra_context) |         context.update(self.extra_context) | ||||||
|         return context |         return context | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| from django.db import models | from django.db import models | ||||||
| 
 | 
 | ||||||
| class ContactEntry(models.Model): | class ContactEntry(models.Model): | ||||||
|  | @ -9,6 +8,6 @@ class ContactEntry(models.Model): | ||||||
|     email = models.EmailField() # should make it unique, but we really cannot |     email = models.EmailField() # should make it unique, but we really cannot | ||||||
|     subscribe_conservancy = models.BooleanField(default=False) |     subscribe_conservancy = models.BooleanField(default=False) | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         ordering = ('email',) |         ordering = ('email',) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| from django.shortcuts import render | from django.shortcuts import render | ||||||
| from django import forms | from django import forms | ||||||
| from conservancy.apps.contacts.models import ContactEntry | from conservancy.apps.contacts.models import ContactEntry | ||||||
|  | @ -9,7 +8,7 @@ def subscribe(request): | ||||||
|     """ |     """ | ||||||
| 
 | 
 | ||||||
|     class ContactEntryForm(ModelForm): |     class ContactEntryForm(ModelForm): | ||||||
|         class Meta(object): |         class Meta: | ||||||
|             model = ContactEntry |             model = ContactEntry | ||||||
| 
 | 
 | ||||||
|     ContactEntryForm.base_fields['subscribe_conservancy'].label = 'Receive Software Freedom Conservancy updates' |     ContactEntryForm.base_fields['subscribe_conservancy'].label = 'Receive Software Freedom Conservancy updates' | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| from django.db import models | from django.db import models | ||||||
| from conservancy.apps.staff.models import Person | from conservancy.apps.staff.models import Person | ||||||
| from conservancy.apps.worldmap.models import EarthLocation | from conservancy.apps.worldmap.models import EarthLocation | ||||||
|  | @ -21,13 +20,13 @@ class PastEventManager(models.Manager): | ||||||
|     """Returns all past events""" |     """Returns all past events""" | ||||||
| 
 | 
 | ||||||
|     def get_queryset(self): |     def get_queryset(self): | ||||||
|         return super(PastEventManager, self).get_queryset().filter(date__lt=datetime.today()) |         return super().get_queryset().filter(date__lt=datetime.today()) | ||||||
| 
 | 
 | ||||||
| class FutureEventManager(models.Manager): | class FutureEventManager(models.Manager): | ||||||
|     """Returns all future events""" |     """Returns all future events""" | ||||||
| 
 | 
 | ||||||
|     def get_queryset(self): |     def get_queryset(self): | ||||||
|         return super(FutureEventManager, self).get_queryset().filter(date__gte=datetime.today()) |         return super().get_queryset().filter(date__gte=datetime.today()) | ||||||
| 
 | 
 | ||||||
| class Event(models.Model): | class Event(models.Model): | ||||||
|     """Model for Conservancy staff member events (presentations, etc)""" |     """Model for Conservancy staff member events (presentations, etc)""" | ||||||
|  | @ -47,14 +46,14 @@ class Event(models.Model): | ||||||
|     date_created = models.DateTimeField(auto_now_add=True) |     date_created = models.DateTimeField(auto_now_add=True) | ||||||
|     date_last_modified = models.DateTimeField(auto_now=True) |     date_last_modified = models.DateTimeField(auto_now=True) | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         ordering = ("-date",) |         ordering = ("-date",) | ||||||
| 
 | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return u"%s (%s)" % (self.title, self.date) |         return "{} ({})".format(self.title, self.date) | ||||||
| 
 | 
 | ||||||
|     def get_absolute_url(self): |     def get_absolute_url(self): | ||||||
|         return u"/events/%s/%s/" % (self.date.strftime("%Y"), self.slug) |         return "/events/{}/{}/".format(self.date.strftime("%Y"), self.slug) | ||||||
| 
 | 
 | ||||||
|     def day_after(self): |     def day_after(self): | ||||||
|         return self.date + timedelta(days=1) |         return self.date + timedelta(days=1) | ||||||
|  | @ -87,9 +86,9 @@ class EventMedia(models.Model): | ||||||
|     date_created = models.DateTimeField(auto_now_add=True) |     date_created = models.DateTimeField(auto_now_add=True) | ||||||
|     date_last_modified = models.DateTimeField(auto_now=True) |     date_last_modified = models.DateTimeField(auto_now=True) | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         verbose_name_plural = 'event media' |         verbose_name_plural = 'event media' | ||||||
| 
 | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return u"%s media: %s" % (self.event, self.format) |         return "{} media: {}".format(self.event, self.format) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ def organize_media_by_event(eventmedia_queryset): | ||||||
|         media_by_event.setdefault(media.event.id, []).append(media) |         media_by_event.setdefault(media.event.id, []).append(media) | ||||||
|     mbe = [{'event': x[0].event, |     mbe = [{'event': x[0].event, | ||||||
|             'date': max(y.date_created for y in x), |             'date': max(y.date_created for y in x), | ||||||
|             'media_list': ', '.join(set(y.get_format_display() for y in x))} |             'media_list': ', '.join({y.get_format_display() for y in x})} | ||||||
|            for x in list(media_by_event.values())] |            for x in list(media_by_event.values())] | ||||||
|     mbe.sort(key=(lambda x: x['date']), reverse=True) # sort by date |     mbe.sort(key=(lambda x: x['date']), reverse=True) # sort by date | ||||||
|     return mbe |     return mbe | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.11.29 on 2023-01-27 06:19 | # Generated by Django 1.11.29 on 2023-01-27 06:19 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
| import uuid | import uuid | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.11.29 on 2023-01-30 18:41 | # Generated by Django 1.11.29 on 2023-01-30 18:41 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.10.7 on 2018-11-18 12:09 | # Generated by Django 1.10.7 on 2018-11-18 12:09 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.10.7 on 2018-11-18 12:11 | # Generated by Django 1.10.7 on 2018-11-18 12:11 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
| import django.db.models.deletion | import django.db.models.deletion | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.10.7 on 2021-11-19 01:45 | # Generated by Django 1.10.7 on 2021-11-19 01:45 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| from __future__ import division |  | ||||||
| from builtins import object |  | ||||||
| import random | import random | ||||||
| 
 | 
 | ||||||
| from django.db import models | from django.db import models | ||||||
|  | @ -21,7 +19,7 @@ class FundraisingGoal(models.Model): | ||||||
|     def percentage_there(self): |     def percentage_there(self): | ||||||
|         return self.fundraiser_so_far_amount / self.fundraiser_goal_amount * 100 |         return self.fundraiser_so_far_amount / self.fundraiser_goal_amount * 100 | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         ordering = ('fundraiser_code_name',) |         ordering = ('fundraiser_code_name',) | ||||||
| 
 | 
 | ||||||
|     def providers(self): |     def providers(self): | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| from django.db import models | from django.db import models | ||||||
| from django.conf import settings | from django.conf import settings | ||||||
| from conservancy import bsoup | from conservancy import bsoup | ||||||
|  | @ -22,7 +21,7 @@ class PressRelease(models.Model, bsoup.SoupModelMixin): | ||||||
| 
 | 
 | ||||||
|     date_last_modified = models.DateTimeField(auto_now=True) |     date_last_modified = models.DateTimeField(auto_now=True) | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         ordering = ("-pub_date",) |         ordering = ("-pub_date",) | ||||||
|         get_latest_by = "pub_date" |         get_latest_by = "pub_date" | ||||||
| 
 | 
 | ||||||
|  | @ -32,7 +31,7 @@ class PressRelease(models.Model, bsoup.SoupModelMixin): | ||||||
|         return self.headline |         return self.headline | ||||||
| 
 | 
 | ||||||
|     def get_absolute_url(self): |     def get_absolute_url(self): | ||||||
|         return u"/news/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(), |         return "/news/{}/{}/".format(self.pub_date.strftime("%Y/%b/%d").lower(), | ||||||
|                                   self.slug) |                                   self.slug) | ||||||
| 
 | 
 | ||||||
|     def is_recent(self): |     def is_recent(self): | ||||||
|  | @ -46,7 +45,7 @@ class PressRelease(models.Model, bsoup.SoupModelMixin): | ||||||
| 
 | 
 | ||||||
|     def save(self): |     def save(self): | ||||||
|         if settings.CONSERVANCY_DEVEL or True: |         if settings.CONSERVANCY_DEVEL or True: | ||||||
|             super(PressRelease, self).save() |             super().save() | ||||||
|             return |             return | ||||||
| 
 | 
 | ||||||
|         blog_name = 'Software Freedom Conservancy News' |         blog_name = 'Software Freedom Conservancy News' | ||||||
|  | @ -65,7 +64,7 @@ class PressRelease(models.Model, bsoup.SoupModelMixin): | ||||||
|         reply = j.weblogUpdates.ping(blog_name, blog_url, post_url) |         reply = j.weblogUpdates.ping(blog_name, blog_url, post_url) | ||||||
| 
 | 
 | ||||||
|         # Call any superclass's method |         # Call any superclass's method | ||||||
|         super(PressRelease, self).save() |         super().save() | ||||||
| 
 | 
 | ||||||
| class ExternalArticleTag(models.Model): | class ExternalArticleTag(models.Model): | ||||||
|     """A way to tag external articles""" |     """A way to tag external articles""" | ||||||
|  | @ -79,7 +78,7 @@ class ExternalArticleTag(models.Model): | ||||||
| 
 | 
 | ||||||
| class PublicExternalArticleManager(models.Manager): | class PublicExternalArticleManager(models.Manager): | ||||||
|     def get_queryset(self): |     def get_queryset(self): | ||||||
|         return super(PublicExternalArticleManager, self).get_queryset().filter(visible=True) |         return super().get_queryset().filter(visible=True) | ||||||
| 
 | 
 | ||||||
| class ExternalArticle(models.Model): | class ExternalArticle(models.Model): | ||||||
|     """A system for displaying Conservancy news mentions on the site. |     """A system for displaying Conservancy news mentions on the site. | ||||||
|  | @ -103,12 +102,12 @@ class ExternalArticle(models.Model): | ||||||
| 
 | 
 | ||||||
|     date_created = models.DateField(auto_now_add=True) |     date_created = models.DateField(auto_now_add=True) | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         ordering = ("-date_created",) |         ordering = ("-date_created",) | ||||||
|         get_latest_by = "date_created" |         get_latest_by = "date_created" | ||||||
| 
 | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return u"%s (%s)" % (self.title, self.publication) |         return "{} ({})".format(self.title, self.publication) | ||||||
| 
 | 
 | ||||||
|     objects = models.Manager() |     objects = models.Manager() | ||||||
|     public = PublicExternalArticleManager() |     public = PublicExternalArticleManager() | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import zip |  | ||||||
| import urllib.parse | import urllib.parse | ||||||
| 
 | 
 | ||||||
| from django import template | from django import template | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ from django.http import HttpResponse | ||||||
| class NewsListView(ListView): | class NewsListView(ListView): | ||||||
|     extra_context = {} |     extra_context = {} | ||||||
|     def get_context_data(self, **kwargs): |     def get_context_data(self, **kwargs): | ||||||
|         context = super(NewsListView, self).get_context_data(**kwargs) |         context = super().get_context_data(**kwargs) | ||||||
|         # context['key'] = 'value' |         # context['key'] = 'value' | ||||||
|         context.update(self.extra_context) |         context.update(self.extra_context) | ||||||
|         return context |         return context | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.10.7 on 2021-11-28 21:12 | # Generated by Django 1.10.7 on 2021-11-28 21:12 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| # -*- coding: utf-8 -*- |  | ||||||
| # Generated by Django 1.10.7 on 2021-11-28 21:12 | # Generated by Django 1.10.7 on 2021-11-28 21:12 | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 | 
 | ||||||
| from django.db import migrations, models | from django.db import migrations, models | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| from django.db import models | from django.db import models | ||||||
| 
 | 
 | ||||||
| class Person(models.Model): | class Person(models.Model): | ||||||
|  | @ -20,11 +19,11 @@ class Person(models.Model): | ||||||
|     date_created = models.DateTimeField(auto_now_add=True) |     date_created = models.DateTimeField(auto_now_add=True) | ||||||
|     date_last_modified = models.DateTimeField(auto_now=True) |     date_last_modified = models.DateTimeField(auto_now=True) | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         verbose_name_plural = 'people' |         verbose_name_plural = 'people' | ||||||
| 
 | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return self.username |         return self.username | ||||||
| 
 | 
 | ||||||
|     def biography_url(self): |     def biography_url(self): | ||||||
|         return u"/about/#%s" % self.username |         return "/about/#%s" % self.username | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| from django.db import models | from django.db import models | ||||||
| 
 | 
 | ||||||
| class SummitRegistration(models.Model): | class SummitRegistration(models.Model): | ||||||
|  | @ -12,6 +11,6 @@ class SummitRegistration(models.Model): | ||||||
|     date_created = models.DateField(auto_now_add=True) |     date_created = models.DateField(auto_now_add=True) | ||||||
|     cle_credit = models.BooleanField(default=True) |     cle_credit = models.BooleanField(default=True) | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         ordering = ('name',) |         ordering = ('name',) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| from django.shortcuts import render | from django.shortcuts import render | ||||||
| from django import forms | from django import forms | ||||||
| from conervancy.apps.summit_registration.models import SummitRegistration | from conervancy.apps.summit_registration.models import SummitRegistration | ||||||
|  | @ -8,7 +7,7 @@ def register(request): | ||||||
|     """ |     """ | ||||||
| 
 | 
 | ||||||
|     class SummitForm(ModelForm): |     class SummitForm(ModelForm): | ||||||
|         class Meta(object): |         class Meta: | ||||||
|             model = SummitRegistration |             model = SummitRegistration | ||||||
| 
 | 
 | ||||||
|     SummitForm.base_fields['email'].label = 'Email address' |     SummitForm.base_fields['email'].label = 'Email address' | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| from django.db import models | from django.db import models | ||||||
| 
 | 
 | ||||||
| class Supporter(models.Model): | class Supporter(models.Model): | ||||||
|  | @ -13,5 +12,5 @@ class Supporter(models.Model): | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return self.display_name |         return self.display_name | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         ordering = ('ledger_entity_id',) |         ordering = ('ledger_entity_id',) | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import object |  | ||||||
| from django.db import models | from django.db import models | ||||||
| 
 | 
 | ||||||
| class EarthLocation(models.Model): | class EarthLocation(models.Model): | ||||||
|  | @ -11,7 +10,7 @@ class EarthLocation(models.Model): | ||||||
|     date_created = models.DateTimeField(auto_now_add=True) |     date_created = models.DateTimeField(auto_now_add=True) | ||||||
|     date_last_modified = models.DateTimeField(auto_now=True) |     date_last_modified = models.DateTimeField(auto_now=True) | ||||||
| 
 | 
 | ||||||
|     class Meta(object): |     class Meta: | ||||||
|         unique_together = (("latitude", "longitude"),) |         unique_together = (("latitude", "longitude"),) | ||||||
| 
 | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|  |  | ||||||
|  | @ -1,7 +1,3 @@ | ||||||
| # -*- encoding: utf-8 -*- |  | ||||||
| 
 |  | ||||||
| from builtins import filter |  | ||||||
| from builtins import object |  | ||||||
| import io | import io | ||||||
| import itertools | import itertools | ||||||
| import re | import re | ||||||
|  | @ -27,7 +23,7 @@ class BeautifulSoup(bs4.BeautifulSoup): | ||||||
|         # for speed, but that doesn't work in our web application.  On |         # for speed, but that doesn't work in our web application.  On | ||||||
|         # Debian stretch, at least, using lxml causes the web server WSGI |         # Debian stretch, at least, using lxml causes the web server WSGI | ||||||
|         # application to go into an infinite loop. |         # application to go into an infinite loop. | ||||||
|         super(BeautifulSoup, self).__init__(src, parser) |         super().__init__(src, parser) | ||||||
| 
 | 
 | ||||||
|     def _body_text(self, root): |     def _body_text(self, root): | ||||||
|         # "Body text" is all the strings under the root element, in order, |         # "Body text" is all the strings under the root element, in order, | ||||||
|  | @ -47,8 +43,7 @@ class BeautifulSoup(bs4.BeautifulSoup): | ||||||
|                     if not started: |                     if not started: | ||||||
|                         break |                         break | ||||||
|                 else: |                 else: | ||||||
|                     for s in self._body_text(child): |                     yield from self._body_text(child) | ||||||
|                         yield s |  | ||||||
|             # It's not worth it to use issubclass here, because elements that |             # It's not worth it to use issubclass here, because elements that | ||||||
|             # don't have body text like Comments and CDATA are subclasses of |             # don't have body text like Comments and CDATA are subclasses of | ||||||
|             # NavigableString. |             # NavigableString. | ||||||
|  | @ -107,7 +102,7 @@ class BeautifulSoup(bs4.BeautifulSoup): | ||||||
|         return self.find_all(self.is_video_source, src=True) |         return self.find_all(self.is_video_source, src=True) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class SoupModelMixin(object): | class SoupModelMixin: | ||||||
|     """Mixin for models to parse HTML with BeautifulSoup. |     """Mixin for models to parse HTML with BeautifulSoup. | ||||||
| 
 | 
 | ||||||
|     Classes that use this mixin must define `SOUP_ATTRS`, a list of strings |     Classes that use this mixin must define `SOUP_ATTRS`, a list of strings | ||||||
|  | @ -153,7 +148,7 @@ class SoupModelMixin(object): | ||||||
| 
 | 
 | ||||||
|     def get_description(self): |     def get_description(self): | ||||||
|         """Return a string with a brief excerpt of body text from the HTML.""" |         """Return a string with a brief excerpt of body text from the HTML.""" | ||||||
|         return u''.join(self._get_soup().some_body_text()) |         return ''.join(self._get_soup().some_body_text()) | ||||||
| 
 | 
 | ||||||
|     def get_image_urls(self, *slice_args): |     def get_image_urls(self, *slice_args): | ||||||
|         """Return an iterator of source URL strings of all images in the HTML. |         """Return an iterator of source URL strings of all images in the HTML. | ||||||
|  |  | ||||||
|  | @ -53,7 +53,7 @@ class PressReleaseFeed(Feed): | ||||||
| 
 | 
 | ||||||
| class OmnibusFeedType(Rss201rev2Feed): | class OmnibusFeedType(Rss201rev2Feed): | ||||||
|     def root_attributes(self): |     def root_attributes(self): | ||||||
|         attrs = super(OmnibusFeedType, self).root_attributes() |         attrs = super().root_attributes() | ||||||
|         attrs['xmlns:itunes'] = 'http://www.itunes.com/dtds/podcast-1.0.dtd' |         attrs['xmlns:itunes'] = 'http://www.itunes.com/dtds/podcast-1.0.dtd' | ||||||
|         attrs['xmlns:atom'] = 'http://www.w3.org/2005/Atom' |         attrs['xmlns:atom'] = 'http://www.w3.org/2005/Atom' | ||||||
|         attrs['xmlns:media'] = 'http://search.yahoo.com/mrss/' |         attrs['xmlns:media'] = 'http://search.yahoo.com/mrss/' | ||||||
|  | @ -61,10 +61,10 @@ class OmnibusFeedType(Rss201rev2Feed): | ||||||
|         return attrs |         return attrs | ||||||
| 
 | 
 | ||||||
|     def add_root_elements(self, handler): |     def add_root_elements(self, handler): | ||||||
|         super(OmnibusFeedType, self).add_root_elements(handler) |         super().add_root_elements(handler) | ||||||
| 
 | 
 | ||||||
|     def add_item_elements(self, handler, item): |     def add_item_elements(self, handler, item): | ||||||
|         super(OmnibusFeedType, self).add_item_elements(handler, item) |         super().add_item_elements(handler, item) | ||||||
|         # Block things that don't have an enclosure from iTunes in |         # Block things that don't have an enclosure from iTunes in | ||||||
|         # case someone uploads this feed there. |         # case someone uploads this feed there. | ||||||
|         handler.addQuickElement("itunes:block", 'Yes') |         handler.addQuickElement("itunes:block", 'Yes') | ||||||
|  | @ -147,7 +147,7 @@ class OmnibusFeed(ConservancyFeedBase): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     def item_extra_kwargs(self, item): |     def item_extra_kwargs(self, item): | ||||||
|         return super(OmnibusFeed, self).item_extra_kwargs(item) |         return super().item_extra_kwargs(item) | ||||||
| 
 | 
 | ||||||
| class BlogFeed(ConservancyFeedBase): | class BlogFeed(ConservancyFeedBase): | ||||||
|     link = "/blog/" |     link = "/blog/" | ||||||
|  | @ -234,7 +234,7 @@ class BlogFeed(ConservancyFeedBase): | ||||||
|         def OR_filter(field_name, subfield_name, objs): |         def OR_filter(field_name, subfield_name, objs): | ||||||
|             from django.db.models import Q |             from django.db.models import Q | ||||||
|             return reduce(lambda x, y: x | y, |             return reduce(lambda x, y: x | y, | ||||||
|                           [Q(**{'%s__%s' % (field_name, subfield_name): x}) |                           [Q(**{'{}__{}'.format(field_name, subfield_name): x}) | ||||||
|                            for x in objs]) |                            for x in objs]) | ||||||
| 
 | 
 | ||||||
|         queryset = BlogEntry.objects.filter(pub_date__lte=datetime.now()) |         queryset = BlogEntry.objects.filter(pub_date__lte=datetime.now()) | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| from __future__ import unicode_literals |  | ||||||
| 
 |  | ||||||
| from datetime import datetime as DateTime | from datetime import datetime as DateTime | ||||||
| 
 | 
 | ||||||
| import conservancy.settings | import conservancy.settings | ||||||
|  | @ -21,9 +19,9 @@ def sitefundraiser(request): | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| if conservancy.settings.FORCE_CANONICAL_HOSTNAME: | if conservancy.settings.FORCE_CANONICAL_HOSTNAME: | ||||||
|     _HOST_URL_VAR = {'host_url': u'https://' + conservancy.settings.FORCE_CANONICAL_HOSTNAME} |     _HOST_URL_VAR = {'host_url': 'https://' + conservancy.settings.FORCE_CANONICAL_HOSTNAME} | ||||||
|     def host_url(request): |     def host_url(request): | ||||||
|         return _HOST_URL_VAR |         return _HOST_URL_VAR | ||||||
| else: | else: | ||||||
|     def host_url(request): |     def host_url(request): | ||||||
|         return {'host_url': request.build_absolute_uri(u'/').rstrip(u'/')} |         return {'host_url': request.build_absolute_uri('/').rstrip('/')} | ||||||
|  |  | ||||||
|  | @ -1,9 +1,8 @@ | ||||||
| from builtins import object |  | ||||||
| from django import http | from django import http | ||||||
| from django.conf import settings | from django.conf import settings | ||||||
| from django.utils.cache import patch_response_headers | from django.utils.cache import patch_response_headers | ||||||
| 
 | 
 | ||||||
| class ForceCanonicalHostnameMiddleware(object): | class ForceCanonicalHostnameMiddleware: | ||||||
| 
 | 
 | ||||||
|     def process_request(self, request): |     def process_request(self, request): | ||||||
|         """Modified common middleware for Conservancy site |         """Modified common middleware for Conservancy site | ||||||
|  | @ -28,7 +27,7 @@ class ForceCanonicalHostnameMiddleware(object): | ||||||
|         if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]): |         if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]): | ||||||
|             new_url[1] = new_url[1] + '/' |             new_url[1] = new_url[1] + '/' | ||||||
|             if settings.DEBUG and request.method == 'POST': |             if settings.DEBUG and request.method == 'POST': | ||||||
|                 raise(RuntimeError, "You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to %s%s (note the trailing slash), or set APPEND_SLASH=False in your Django settings." % (new_url[0], new_url[1])) |                 raise(RuntimeError, "You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to {}{} (note the trailing slash), or set APPEND_SLASH=False in your Django settings.".format(new_url[0], new_url[1])) | ||||||
|         # Strip trailing index.html |         # Strip trailing index.html | ||||||
|         if new_url[1].endswith('/index.html'): |         if new_url[1].endswith('/index.html'): | ||||||
|             new_url[1] = new_url[1][:new_url[1].rfind('index.html')] |             new_url[1] = new_url[1][:new_url[1].rfind('index.html')] | ||||||
|  | @ -42,7 +41,7 @@ class ForceCanonicalHostnameMiddleware(object): | ||||||
|                 new_url[0] = settings.FORCE_CANONICAL_HOSTNAME |                 new_url[0] = settings.FORCE_CANONICAL_HOSTNAME | ||||||
|             # Redirect |             # Redirect | ||||||
|             if new_url[0]: |             if new_url[0]: | ||||||
|                 newurl = "%s://%s%s" % (request.is_secure() and 'https' or 'http', new_url[0], new_url[1]) |                 newurl = "{}://{}{}".format(request.is_secure() and 'https' or 'http', new_url[0], new_url[1]) | ||||||
|             else: |             else: | ||||||
|                 newurl = new_url[1] |                 newurl = new_url[1] | ||||||
|             if request.GET: |             if request.GET: | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ ROOT_URLCONF = 'conservancy.urls' | ||||||
| 
 | 
 | ||||||
| FORCE_CANONICAL_HOSTNAME = False if DEBUG else 'sfconservancy.org' | FORCE_CANONICAL_HOSTNAME = False if DEBUG else 'sfconservancy.org' | ||||||
| 
 | 
 | ||||||
| ALLOWED_HOSTS = [ 'www.sfconservancy.org', 'aspen.sfconservancy.org', 'sfconservancy.org',  u'104.130.70.210' ] | ALLOWED_HOSTS = [ 'www.sfconservancy.org', 'aspen.sfconservancy.org', 'sfconservancy.org',  '104.130.70.210' ] | ||||||
| if DEBUG: | if DEBUG: | ||||||
|     ALLOWED_HOSTS.append('localhost') |     ALLOWED_HOSTS.append('localhost') | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import str |  | ||||||
| import mimetypes | import mimetypes | ||||||
| import os.path | import os.path | ||||||
| from django.http import HttpResponse | from django.http import HttpResponse | ||||||
|  | @ -30,9 +29,9 @@ def handler500(request): | ||||||
|     return handler(request, 500) |     return handler(request, 500) | ||||||
| 
 | 
 | ||||||
| def index(request, *args, **kwargs): | def index(request, *args, **kwargs): | ||||||
|     path = request.path.lstrip(u'/') |     path = request.path.lstrip('/') | ||||||
|     if path.endswith(u'/'): |     if path.endswith('/'): | ||||||
|         path += u'index.html' |         path += 'index.html' | ||||||
|     fullpath = os.path.join(STATIC_ROOT, path) |     fullpath = os.path.join(STATIC_ROOT, path) | ||||||
|     try: |     try: | ||||||
|         # Junk URLs in production (Python 3.5) are causing UnicodeEncodeErrors |         # Junk URLs in production (Python 3.5) are causing UnicodeEncodeErrors | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| from builtins import str |  | ||||||
| from mod_python import apache | from mod_python import apache | ||||||
| 
 | 
 | ||||||
| # 404 should do NOTHING so apache can handle it.  This view is referenced | # 404 should do NOTHING so apache can handle it.  This view is referenced | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue