Changeset - 47a30a750ad1
[Not reviewed]
0 45 0
Ben Sturmfels (bsturmfels) - 7 months ago 2023-10-19 22:52:39
ben@sturm.com.au
Sort Python imports with isort
45 files changed with 103 insertions and 51 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/assignment/migrations/0002_auto_20211206_2237.py
Show inline comments
 
# Generated by Django 1.11.29 on 2021-12-06 22:37
 

	
 
import datetime
 

	
 
from django.db import migrations, models
 
import django_countries.fields
 

	
 

	
 
class Migration(migrations.Migration):
 

	
www/conservancy/apps/assignment/migrations/0003_auto_20211206_2249.py
Show inline comments
 
# Generated by Django 1.11.29 on 2021-12-06 22:49
 

	
 
from django.db import migrations, models
 
import uuid
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('assignment', '0002_auto_20211206_2237'),
 
    ]
www/conservancy/apps/assignment/migrations/0004_auto_20230127_0602.py
Show inline comments
 
# Generated by Django 1.11.29 on 2023-01-27 06:02
 

	
 
from django.db import migrations, models
 

	
 
from ..models import validate_mutiple_urls
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('assignment', '0003_auto_20211206_2249'),
 
    ]
 

	
www/conservancy/apps/assignment/urls.py
Show inline comments
 
from django.conf.urls import url
 

	
 
from .views import AssignmentCreateView, AssignmentThanksView
 

	
 

	
 
urlpatterns = [
 
    url(r'^$', AssignmentCreateView.as_view(), name='assignement-add'),
 
    url(r'^(?P<pk>[\w-]+)/$', AssignmentThanksView.as_view(), name='assignment-thanks'),
 
]
www/conservancy/apps/assignment/views.py
Show inline comments
...
 
@@ -3,12 +3,13 @@ from django.urls import reverse_lazy
 
from django.views.generic import DetailView
 
from django.views.generic.edit import CreateView
 

	
 
from .forms import AssignmentForm
 
from .models import Assignment
 

	
 

	
 
class AssignmentCreateView(CreateView):
 
    """Show a form for the initial  copyright assignment."""
 

	
 
    form_class = AssignmentForm
 
    template_name = 'assignment/assignment_form.html'
 

	
www/conservancy/apps/blog/admin.py
Show inline comments
 
from django.contrib import admin
 

	
 
from .models import EntryTag, Entry
 
from .models import Entry, EntryTag
 

	
 

	
 
class EntryTagAdmin(admin.ModelAdmin):
 
    prepopulated_fields = {'slug': ('label',)}
 

	
 
admin.site.register(EntryTag, EntryTagAdmin)
www/conservancy/apps/blog/models.py
Show inline comments
 
from datetime import datetime, timedelta
 

	
 
from django.db import models
 
from django.conf import settings
 
from django.db import models
 

	
 
from ... import bsoup
 
from ..staff.models import Person
 

	
 

	
 
class EntryTag(models.Model):
www/conservancy/apps/blog/urls.py
Show inline comments
 
from datetime import datetime
 

	
 
from django.conf.urls import url, include
 
from django.conf.urls import include, url
 

	
 
from .models import Entry, EntryTag
 
from ..staff.models import Person
 
from .views import last_name, BlogYearArchiveView, BlogMonthArchiveView, BlogDayArchiveView, BlogDateDetailView, custom_index, query
 
from .models import Entry, EntryTag
 
from .views import (
 
    BlogDateDetailView,
 
    BlogDayArchiveView,
 
    BlogMonthArchiveView,
 
    BlogYearArchiveView,
 
    custom_index,
 
    last_name,
 
    query,
 
)
 

	
 
extra_context = {}
 

	
 
info_dict = {
 
    'queryset': Entry.objects.all(),
 
    'date_field': 'pub_date',
www/conservancy/apps/blog/views.py
Show inline comments
 
from datetime import datetime
 
from functools import reduce
 

	
 
from django.views.generic import ListView
 
from django.views.generic.dates import YearArchiveView, MonthArchiveView, DayArchiveView, DateDetailView
 
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
 
from django.shortcuts import get_object_or_404, render
 
from django.views.generic import ListView
 
from django.views.generic.dates import (
 
    DateDetailView,
 
    DayArchiveView,
 
    MonthArchiveView,
 
    YearArchiveView,
 
)
 

	
 
from .models import Entry, EntryTag
 
from ..staff.models import Person
 
from .models import Entry, EntryTag
 

	
 

	
 
def OR_filter(field_name, objs):
 
    from django.db.models import Q
 
    return reduce(lambda x, y: x | y,
 
                  [Q(**{field_name: x.id}) for x in objs])
www/conservancy/apps/contacts/models.py
Show inline comments
 
from django.db import models
 

	
 

	
 
class ContactEntry(models.Model):
 
    """Conservancy contact system
 

	
 
    Hopefully this will be deprecated soon"""
 

	
 
    email = models.EmailField() # should make it unique, but we really cannot
www/conservancy/apps/contacts/urls.py
Show inline comments
 
from django.conf.urls import patterns, url, include
 
from django.conf.urls import include, patterns, url
 

	
 
urlpatterns = patterns('conservancy.apps.contacts.views',
 
   (r'^/?$', 'subscribe'),
 
)
www/conservancy/apps/contacts/views.py
Show inline comments
 
from django.shortcuts import render
 
from django import forms
 
from django.forms import ModelForm
 
from django.shortcuts import render
 

	
 
from .models import ContactEntry
 

	
 

	
 
def subscribe(request):
 
    """Mailing list subscription form
www/conservancy/apps/contractpatch/urls.py
Show inline comments
 
from django.conf.urls import url, include
 
from django.conf.urls import include, url
 

	
 
from . import views as cpatch_views
 

	
 
urlpatterns = [
 
    url(r'', cpatch_views.index),
 
]
www/conservancy/apps/events/admin.py
Show inline comments
 
from django.contrib import admin
 

	
 
from .models import EventTag, Event, EventMedia
 
from .models import Event, EventMedia, EventTag
 

	
 
admin.site.register(EventTag)
 

	
 
class EventAdmin(admin.ModelAdmin):
 
    list_display = ("title", "date", "date_tentative", "location")
 
    list_filter = ['date']
www/conservancy/apps/events/urls.py
Show inline comments
 
from django.conf.urls import patterns, url, include
 
from django.conf.urls import include, patterns, url
 

	
 
from .models import Event
 

	
 
info_dict = {
 
    'queryset': Event.objects.all(),
 
    'date_field': 'date',
www/conservancy/apps/events/views.py
Show inline comments
 
# from django.views.generic.list_detail import object_list
 
from django.shortcuts import render
 
from django.core.exceptions import ObjectDoesNotExist
 
from django.http import Http404, HttpResponse
 
from django.shortcuts import render
 
from django.template import loader
 
from django.core.exceptions import ObjectDoesNotExist
 

	
 
from .models import Event
 

	
 

	
 
def event_detail(request, year, slug, queryset, **kwargs):
 
    """This view shows event detail.
www/conservancy/apps/fossy/migrations/0001_initial.py
Show inline comments
 
# Generated by Django 1.11.29 on 2023-01-27 06:19
 

	
 
from django.db import migrations, models
 
import uuid
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    initial = True
 

	
 
    dependencies = [
www/conservancy/apps/fossy/urls.py
Show inline comments
 
from django.conf.urls import url
 

	
 
from .views import CommunityTrackProposalCreateView, CommunityTrackProposalThanksView
 

	
 

	
 
urlpatterns = [
 
    url(r'^community-tracks/$', CommunityTrackProposalCreateView.as_view(), name='fossy-add'),
 
    url(r'^(?P<pk>[\w-]+)/$', CommunityTrackProposalThanksView.as_view(), name='fossy-thanks'),
 
]
www/conservancy/apps/news/admin.py
Show inline comments
 
from django.contrib import admin
 

	
 
from .models import PressRelease, ExternalArticleTag, ExternalArticle
 
from .models import ExternalArticle, ExternalArticleTag, PressRelease
 

	
 

	
 
class PressReleaseAdmin(admin.ModelAdmin):
 
    list_display = ("headline", "pub_date")
 
    list_filter = ['pub_date']
 
    date_hierarchy = 'pub_date'
www/conservancy/apps/news/models.py
Show inline comments
 
from datetime import datetime, timedelta
 

	
 
from django.db import models
 
from django.conf import settings
 
from django.contrib.sites.models import Site
 
from django.db import models
 

	
 
from ... import bsoup
 
from ..staff.models import Person
 
from ..events.models import Event
 
from ..staff.models import Person
 

	
 

	
 
class PressRelease(models.Model, bsoup.SoupModelMixin):
 
    """News release model"""
 

	
 
    headline = models.CharField(max_length=300)
www/conservancy/apps/news/templatetags/date_within.py
Show inline comments
 
from datetime import datetime, timedelta
 

	
 
from django import template
 
from datetime import timedelta, datetime
 

	
 
register = template.Library()
 

	
 
@register.filter
 
def date_within_past_days(value, arg):
 
    # question: does datetime.now() do a syscall each time is it called?
www/conservancy/apps/news/templatetags/min.py
Show inline comments
 
from django import template
 

	
 
register = template.Library()
 

	
 
@register.filter
 
def min(value, arg):
 
    if value > arg:
 
        return arg
www/conservancy/apps/news/templatetags/subtract.py
Show inline comments
 
from django import template
 

	
 
register = template.Library()
 

	
 
@register.filter
 
def subtract(value, arg):
 
    return value - arg
www/conservancy/apps/news/urls.py
Show inline comments
...
 
@@ -14,17 +14,23 @@
 
# General Public License for more details.
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 

	
 
from django.conf.urls import url, include
 
from django.conf import settings
 
from django.conf.urls import include, url
 

	
 
from .models import PressRelease, ExternalArticle
 
from .views import NewsYearArchiveView, NewsMonthArchiveView, NewsDayArchiveView, NewsDateDetailView, listing
 
from .models import ExternalArticle, PressRelease
 
from .views import (
 
    NewsDateDetailView,
 
    NewsDayArchiveView,
 
    NewsMonthArchiveView,
 
    NewsYearArchiveView,
 
    listing,
 
)
 

	
 
info_dict = {
 
    'queryset': PressRelease.objects.all().filter(sites__id__exact=settings.SITE_ID),
 
    'date_field': 'pub_date',
 
}
 

	
www/conservancy/apps/news/views.py
Show inline comments
 
from datetime import datetime
 

	
 
from django.views.generic import ListView
 
from django.shortcuts import render
 
from django.views.generic.dates import YearArchiveView, MonthArchiveView, DayArchiveView, DateDetailView
 
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
 
from django.http import HttpResponse
 
from django.shortcuts import render
 
from django.views.generic import ListView
 
from django.views.generic.dates import (
 
    DateDetailView,
 
    DayArchiveView,
 
    MonthArchiveView,
 
    YearArchiveView,
 
)
 

	
 
from .models import ExternalArticle
 
from .models import PressRelease
 
from ..events.models import Event
 
from .models import ExternalArticle, PressRelease
 

	
 

	
 
class NewsListView(ListView):
 
    extra_context = {}
 
    def get_context_data(self, **kwargs):
 
        context = super().get_context_data(**kwargs)
www/conservancy/apps/staff/models.py
Show inline comments
 
from django.db import models
 

	
 

	
 
class Person(models.Model):
 
    """Staff members
 

	
 
    Referenced from other models (blog, events, etc)
 
    """
 

	
www/conservancy/apps/summit_registration/models.py
Show inline comments
 
from django.db import models
 

	
 

	
 
class SummitRegistration(models.Model):
 
    """Form fields for summit registrants"""
 

	
 
    name = models.CharField(max_length=300)
 
    affiliation = models.CharField(max_length=700, blank=True)
 
    address = models.TextField(blank=True)
www/conservancy/apps/summit_registration/urls.py
Show inline comments
 
from django.conf.urls import patterns, url, include
 
from django.conf.urls import include, patterns, url
 

	
 
urlpatterns = patterns('conservancy.apps.summit_registration.views',
 
   (r'^/?$', 'register'),
 
)
www/conservancy/apps/summit_registration/views.py
Show inline comments
 
from django.shortcuts import render
 
from django import forms
 
from conervancy.apps.summit_registration.models import SummitRegistration
 
from django import forms
 
from django.shortcuts import render
 

	
 

	
 
def register(request):
 
    """Summit registration form view
 
    """
 

	
 
    class SummitForm(ModelForm):
www/conservancy/apps/supporters/models.py
Show inline comments
 
from django.db import models
 

	
 

	
 
class Supporter(models.Model):
 
    """Conservancy Supporter listing"""
 

	
 
    display_name = models.CharField(max_length=200, blank=False)
 
    display_until_date = models.DateTimeField("date until which this supporter name is displayed")
 
    ledger_entity_id = models.CharField(max_length=200, blank=False)
www/conservancy/apps/worldmap/models.py
Show inline comments
 
from django.db import models
 

	
 

	
 
class EarthLocation(models.Model):
 
    """Represents latitude and longitude, with a label"""
 

	
 
    label = models.CharField(max_length=300, unique=True)
 
    latitude = models.DecimalField(max_digits=9, decimal_places=6)
 
    longitude = models.DecimalField(max_digits=9, decimal_places=6)
www/conservancy/bsoup.py
Show inline comments
...
 
@@ -2,12 +2,13 @@ import io
 
import itertools
 
import re
 

	
 
import bs4
 
import bs4.element
 

	
 

	
 
class BeautifulSoup(bs4.BeautifulSoup):
 
    """A wrapper of the original BeautifulSoup class, with convenience methods added."""
 

	
 
    IMAGE_ATTRS = {
 
        'img': 'src',
 
        'video': 'poster',
www/conservancy/static/projects/policies/publish-policy.py
Show inline comments
...
 
@@ -10,15 +10,15 @@ import shutil
 
import subprocess
 
import sys
 
import tempfile
 

	
 
try:
 
    import markdown
 
    from markdown.extensions import tables as mdx_tables
 
    from markdown.extensions import sane_lists as mdx_sane_lists
 
    from markdown.extensions import smarty as mdx_smarty
 
    from markdown.extensions import tables as mdx_tables
 
    from markdown.extensions import toc as mdx_toc
 
    markdown_import_success = True
 
except ImportError:
 
    if __name__ != '__main__':
 
        raise
 
    markdown_import_success = False
www/conservancy/static/views.py
Show inline comments
 
import mimetypes
 
import os.path
 

	
 
from django.http import HttpResponse
 
from django.template.response import TemplateResponse
 

	
 
from conservancy.local_context_processors import fundgoal_lookup
 

	
 
STATIC_ROOT = os.path.abspath(os.path.dirname(__file__))
www/conservancy/urls.py
Show inline comments
...
 
@@ -14,13 +14,13 @@
 
# General Public License for more details.
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 

	
 
from django.conf.urls import url, include
 
from django.conf.urls import include, url
 
from django.contrib import admin
 

	
 
from . import feeds, frontpage, sponsors
 
from .apps.fundgoal import views as fundgoal_views
 
from .static import views as static_views
 

	
www/conservancy_ssl_wrapper.py
Show inline comments
...
 
@@ -18,10 +18,11 @@
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 

	
 
# req.subprocess_env is not set when the PostReadRequestHandler runs,
 
# so we just bypass it altogether and set the relevant variable here.
 
# See deployment documentation for more info.
 
from os import environ
 

	
 
environ["DJANGO_SETTINGS_MODULE"] = 'conservancy_ssl.settings'
 
environ["CANONICAL_HOSTNAME"] = 'sfconservancy.org'
 

	
 
# from modpythoncustom import *
www/conservancy_wrapper.py
Show inline comments
 
# req.subprocess_env is not set when the PostReadRequestHandler runs,
 
# so we just bypass it altogether and set the relevant variable here.
 
# See deployment documentation for more info.
 
from os import environ
 

	
 
environ["DJANGO_SETTINGS_MODULE"] = 'conservancy.settings'
 
environ["CANONICAL_HOSTNAME"] = 'sfconservancy.org'
 

	
 
# from modpythoncustom import *
www/modpythoncustom.py
Show inline comments
 
from mod_python import apache
 

	
 

	
 
# 404 should do NOTHING so apache can handle it.  This view is referenced
 
# in sflc.urls
 
def view404(request):
 
    from django.http import HttpResponseNotFound
 
    return HttpResponseNotFound("")
 

	
...
 
@@ -27,20 +28,21 @@ def outputfilter(filter):
 

	
 
    # send it off!
 
    filter.write(cooked.encode('utf-8'))
 
    if s is None:
 
        filter.close()
 

	
 
from django.core.handlers.modpython import *
 

	
 
# This is unreferenced from this file, but it must be imported to
 
# enable template inheritance in the outputfilter!
 
import django.template.loader
 

	
 
# And now we override a few things in the module
 
# django.core.handlers.modpython
 

	
 
from django.core.handlers.modpython import *
 
del handler
 

	
 
class ModPythonRequest(ModPythonRequest):
 
    def is_secure(self):
 
        return 'HTTPS' in self._req.get_options() and self._req.get_options()['HTTPS'] == 'on'
 

	
www/podjango/admin.py
Show inline comments
...
 
@@ -15,13 +15,14 @@
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 
#
 
from django.contrib import admin
 

	
 
from .models import CastTag, Cast
 
from .models import Cast, CastTag
 

	
 

	
 
class CastTagAdmin(admin.ModelAdmin):
 
    prepopulated_fields = {'slug': ('label',)}
 

	
 
admin.site.register(CastTag, CastTagAdmin)
 

	
www/podjango/feeds.py
Show inline comments
...
 
@@ -18,17 +18,17 @@
 
#
 

	
 
from datetime import datetime
 
import itertools
 
import operator
 

	
 
from django.conf import settings
 
from django.contrib.sites.shortcuts import get_current_site
 
from django.contrib.syndication.views import add_domain, Feed
 
from django.utils.feedgenerator import Rss201rev2Feed 
 
from django.contrib.syndication.views import Feed, add_domain
 
from django.shortcuts import render
 
from django.conf import settings
 
from django.utils.feedgenerator import Rss201rev2Feed
 

	
 
from .models import Cast
 

	
 
# FIXME: Settings here should not be hard-coded for given casts, but
 
# should instead have settings from the main screen.
 

	
www/podjango/frontpage.py
Show inline comments
...
 
@@ -14,17 +14,19 @@
 
# General Public License for more details.
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 

	
 
from django.shortcuts import render
 
from datetime import datetime, timedelta
 

	
 
from django.shortcuts import render
 

	
 
from .models import Cast
 

	
 

	
 
def view(request):
 
    """Cast front page view
 
    Performs all object queries necessary to render the front page.
 
    """
 

	
 
    cast = Cast.objects.all().filter(pub_date__lte=datetime.now())[:3]
www/podjango/models.py
Show inline comments
...
 
@@ -13,16 +13,17 @@
 
# General Public License for more details.
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 
#
 
from django.db import models
 
from datetime import datetime, timedelta
 

	
 
from django.conf import settings
 
from django.db import models
 
from django.urls import reverse
 
from datetime import datetime, timedelta
 

	
 

	
 
class CastTag(models.Model):
 
    """Tagging for casts"""
 

	
 
    label = models.CharField(max_length=100)
www/podjango/templatetags/date_within.py
Show inline comments
 
from datetime import datetime, timedelta
 

	
 
from django import template
 
from datetime import timedelta, datetime
 

	
 
register = template.Library()
 

	
 
@register.filter
 
def date_within_past_days(value, arg):
 
    # question: does datetime.now() do a syscall each time is it called?
www/podjango/urls.py
Show inline comments
...
 
@@ -15,19 +15,24 @@
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 

	
 
from django.conf import settings
 
from django.conf.urls import url, include
 
from django.conf.urls import include, url
 
from django.contrib import admin
 
from django.contrib.syndication.views import Feed
 
from django.views.generic.dates import DateDetailView, DayArchiveView, MonthArchiveView, YearArchiveView
 
from django.views.generic.dates import (
 
    DateDetailView,
 
    DayArchiveView,
 
    MonthArchiveView,
 
    YearArchiveView,
 
)
 

	
 
from . import frontpage
 
from .feeds import feed_dict, view, Mp3CastFeed, OggCastFeed
 
from .feeds import Mp3CastFeed, OggCastFeed, feed_dict, view
 
from .models import Cast, CastTag
 
from .views import custom_index, query
 

	
 
app_name = 'podjango'
 

	
 
extra_context = {}
www/podjango/views.py
Show inline comments
...
 
@@ -16,14 +16,14 @@
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 
#
 
from datetime import datetime
 
from functools import reduce
 

	
 
from django.views.generic.list import ListView
 
from django.shortcuts import get_object_or_404, render
 
from django.views.generic.list import ListView
 

	
 
from .models import Cast, CastTag
 

	
 

	
 
def OR_filter(field_name, objs):
 
    from django.db.models import Q
0 comments (0 inline, 0 general)