Changeset - 75e3ab4d35f0
[Not reviewed]
0 8 0
Ben Sturmfels (bsturmfels) - 2 months ago 2024-02-23 04:02:04
ben@sturm.com.au
podjango: Fix linting warnings
8 files changed with 84 insertions and 64 deletions:
0 comments (0 inline, 0 general)
TODO.md
Show inline comments
...
 
@@ -2,2 +2,4 @@
 

	
 
* remove `ForceCanonicalHostnameMiddleware` by ensuring canonical redirect and HTTPS redirect is done by Apache
 
* serve a 400 in Apache for a hostname we don't explicitly support
 
* use `<detail>` elements for supporter page hidden sections, rather than complex jQuery - or consider Alpine.js
conservancy/podjango/admin.py
Show inline comments
...
 
@@ -26,4 +26,6 @@ class CastTagAdmin(admin.ModelAdmin):
 

	
 

	
 
admin.site.register(CastTag, CastTagAdmin)
 

	
 

	
 
class CastAdmin(admin.ModelAdmin):
conservancy/podjango/feeds.py
Show inline comments
...
 
@@ -20,6 +20,3 @@
 
from datetime import datetime
 
import itertools
 
import operator
 

	
 
from django.conf import settings
 
from django.contrib.sites.shortcuts import get_current_site
...
 
@@ -55,32 +52,39 @@ class CastFeedBase(Feed):
 
                    break
 
        return { 'year' : year }
 
        return {'year': year}
 

	
 

	
 
def for_podcast_feed_extra_kwargs(self, obj):
 
    return { 'managingEditorNames' : 'Bradley and Karen',
 
             'rssImage' : { 'url' : 'http://faif.us/img/cast/faif_144x144.jpg',
 
                            'width' : '144', 'height' : '144' },
 
             'webMaster' : 'oggcast@faif.us (Bradley and Karen)',
 
             'dcCreator' : 'oggcast@faif.us (Bradley and Karen)',
 
             'iTunesExplicit'  : 'No',
 
             'iTunesBlock' : 'No',
 
             'iTunesImage' : { 'url' : 'http://faif.us/img/cast/faif_300x300.jpg',
 
                               'title' : 'The Corresponding Source (formerly Free as in Freedom)',
 
                               'link' : self.author_link,
 
                               'type' : 'video/jpg'},
 
             'category' : { 'name' : 'Government & Organizations', 'scheme' : 'http://www.itunes.com/dtds/podcast-1.0.dtd',
 
                            'subcats' : [ 'Non-Profit' ] },
 
             'keywords' : 'open source, opensource, freesoftware, software freedom, legal, law, linux, free, license, gpl, lgpl, agpl, bsd',
 
             'iTunesAuthor' : 'Software Freedom Conservancy',
 
             'iTunesSubtitle' : 'Bi-Weekly Discussion of Legal, Policy, and Any other Issues in the Free, Libre, and Open Source Software (FLOSS) Community',
 
             'copyrightHolder' : self.copyright_holder(),
 
             'copyrightLicense' : self.license_no_html() }
 
    return {
 
        'managingEditorNames': 'Bradley and Karen',
 
        'rssImage': {'url': 'http://faif.us/img/cast/faif_144x144.jpg',
 
                     'width': '144', 'height': '144'},
 
        'webMaster': 'oggcast@faif.us (Bradley and Karen)',
 
        'dcCreator': 'oggcast@faif.us (Bradley and Karen)',
 
        'iTunesExplicit': 'No',
 
        'iTunesBlock': 'No',
 
        'iTunesImage': {'url': 'http://faif.us/img/cast/faif_300x300.jpg',
 
                        'title': 'The Corresponding Source (formerly Free as in Freedom)',
 
                        'link': self.author_link,
 
                        'type': 'video/jpg'},
 
        'category': {'name': 'Government & Organizations', 'scheme': 'http://www.itunes.com/dtds/podcast-1.0.dtd',
 
                     'subcats': ['Non-Profit']},
 
        'keywords': 'open source, opensource, freesoftware, software freedom, legal, law, linux, free, license, gpl, lgpl, agpl, bsd',
 
        'iTunesAuthor': 'Software Freedom Conservancy',
 
        'iTunesSubtitle': 'Bi-Weekly Discussion of Legal, Policy, and Any other Issues in the Free, Libre, and Open Source Software (FLOSS) Community',
 
        'copyrightHolder': self.copyright_holder(),
 
        'copyrightLicense': self.license_no_html(),
 
    }
 

	
 

	
 
def for_podcast_item_extra_kwargs(self, item):
 
    return { 'duration' : item.duration,
 
             'year' : item.date_created.year,
 
             'dcCreator' : 'oggcast@faif.us (Bradley and Karen)',
 
             'intheitembkuhn' : item.__dict__.__str__()}
 
    return {
 
        'duration': item.duration,
 
        'year': item.date_created.year,
 
        'dcCreator': 'oggcast@faif.us (Bradley and Karen)',
 
        'intheitembkuhn': item.__dict__.__str__(),
 
    }
 

	
 

	
 
def podcast_helper_add_root_elements(self, handler):
 
    handler.addQuickElement('managingEditor', self.feed['author_email'] 
 
    handler.addQuickElement('managingEditor', self.feed['author_email']
 
                            + ' (' + self.feed['managingEditorNames'] + ')')
...
 
@@ -93,3 +97,3 @@ def podcast_helper_add_root_elements(self, handler):
 
    handler.endElement('image')
 
    
 

 
    handler.addQuickElement('webMaster', self.feed['webMaster'])
...
 
@@ -99,3 +103,3 @@ def podcast_helper_add_root_elements(self, handler):
 
    handler.addQuickElement('generator', 'http://www.faif.us/code')
 
    
 

 
    handler.addQuickElement('media:thumbnail', '' , { 'url' : self.feed['rssImage']['url'] })
...
 
@@ -104,11 +108,11 @@ def podcast_helper_add_root_elements(self, handler):
 
#                                                 'type' : self.feed['iTunesImage']['type']})
 
    
 

 
    handler.addQuickElement("media:category", self.feed['category']['name'],
 
                            { 'scheme': self.feed['category']['scheme']})
 
    if not (self.feed['category']['subcats'] and len(self.feed['category']['subcats']) > 0): 
 
        handler.addQuickElement("itunes:category", '', { 'text': self.feed['category']['name']})
 
                            {'scheme': self.feed['category']['scheme']})
 
    if not (self.feed['category']['subcats'] and len(self.feed['category']['subcats']) > 0):
 
        handler.addQuickElement("itunes:category", '', {'text': self.feed['category']['name']})
 
    else:
 
        handler.startElement("itunes:category", { 'text': self.feed['category']['name']})
 
        handler.startElement("itunes:category", {'text': self.feed['category']['name']})
 
        for cc in self.feed['category']['subcats']:
 
            handler.addQuickElement("itunes:category", '', { 'text': cc })
 
            handler.addQuickElement("itunes:category", '', {'text': cc})
 
        handler.endElement("itunes:category")
...
 
@@ -116,3 +120,3 @@ def podcast_helper_add_root_elements(self, handler):
 
    handler.addQuickElement("media:keywords", self.feed['keywords'].replace(" ", ","))
 
    
 

 
    handler.startElement("itunes:owner", {})
...
 
@@ -121,13 +125,13 @@ def podcast_helper_add_root_elements(self, handler):
 
    handler.endElement("itunes:owner")
 
    
 

 
    handler.addQuickElement("itunes:summary", self.feed['description'])
 
    handler.addQuickElement("itunes:subtitle", self.feed['iTunesSubtitle'])
 
    
 

 
    handler.addQuickElement("itunes:author", self.feed['iTunesAuthor'])
 
    handler.addQuickElement('atom:link', '', { 'rel' : "self",  'href'  : self.feed['feed_url'],
 
                                                'type' : "application/rss+xml"})
 
    
 
    handler.addQuickElement('atom:link', '', {'rel': "self", 'href': self.feed['feed_url'],
 
                                              'type': "application/rss+xml"})
 

	
 
    years = {}
 
    for ii in self.items: years[ii['year']] = 1
 
    
 

 
    copyrightString = ""
...
 
@@ -137,6 +141,7 @@ def podcast_helper_add_root_elements(self, handler):
 
    copyrightString += "%s.  %s" % (self.feed['copyrightHolder'], self.feed['copyrightLicense'])
 
    
 

 
    handler.addQuickElement('copyright', copyrightString)
 
    handler.addQuickElement('media:copyright', "Copyright (C) " + copyrightString)
 
    
 

	
 

	
 
def podcast_helper_add_item_elements(self, handler, item):
...
 
@@ -149,5 +154,5 @@ def podcast_helper_add_item_elements(self, handler, item):
 
    if 'enclosure' in item:
 
        handler.addQuickElement('media:content', '', { 'url' : item['enclosure'].url,
 
                                                       'fileSize' : item['enclosure'].length,
 
                                                       'type' : item['enclosure'].mime_type})
 
        handler.addQuickElement('media:content', '', {'url': item['enclosure'].url,
 
                                                      'fileSize': item['enclosure'].length,
 
                                                      'type': item['enclosure'].mime_type})
 

	
...
 
@@ -212,3 +217,3 @@ class CastFeed(CastFeedBase):
 
    def item_categories(self, item):
 
        return  ('Technology',)
 
        return ('Technology',)
 

	
...
 
@@ -224,3 +229,3 @@ class CastFeed(CastFeedBase):
 

	
 
# FIXME: 
 
# FIXME:
 
# GUEST NAME GOES HERE!!!
...
 
@@ -238,2 +243,3 @@ class Mp3CastFeed(CastFeed):
 

	
 

	
 
class OggCastFeed(CastFeed):
...
 
@@ -245,2 +251,3 @@ class OggCastFeed(CastFeed):
 

	
 

	
 
feed_dict = {
...
 
@@ -254,2 +261,3 @@ for k, v in feed_dict.items():
 

	
 

	
 
def view(request):
conservancy/podjango/frontpage.py
Show inline comments
...
 
@@ -19,3 +19,3 @@
 

	
 
from datetime import datetime, timedelta
 
from datetime import datetime
 

	
conservancy/podjango/models.py
Show inline comments
...
 
@@ -55,6 +55,8 @@ class Cast(models.Model):
 
    tags = models.ManyToManyField(CastTag, blank=True)
 
    ogg_path = models.CharField(max_length=300, blank=True,
 
                             help_text="Local filename of the Ogg file, relative to webroot.  File should be uploaded into the static media area for casts.")
 
    mp3_path = models.CharField(max_length=300, blank=True,
 
                             help_text="Local filename of the mp3 file, relative to webroot.  File should be uploaded into the static media area for casts.")
 
    ogg_path = models.CharField(
 
        max_length=300, blank=True,
 
        help_text="Local filename of the Ogg file, relative to webroot.  File should be uploaded into the static media area for casts.")
 
    mp3_path = models.CharField(
 
        max_length=300, blank=True,
 
        help_text="Local filename of the mp3 file, relative to webroot.  File should be uploaded into the static media area for casts.")
 
    ogg_length = models.IntegerField(blank=False, help_text="size in bytes of ogg file")
conservancy/podjango/templatetags/date_within.py
Show inline comments
...
 
@@ -6,2 +6,3 @@ register = template.Library()
 

	
 

	
 
@register.filter
conservancy/podjango/urls.py
Show inline comments
...
 
@@ -19,6 +19,6 @@
 

	
 
import datetime
 

	
 
from django.conf import settings
 
from django.conf.urls import include, url
 
from django.contrib import admin
 
from django.contrib.syndication.views import Feed
 
from django.conf.urls import url
 
from django.views.generic.dates import (
...
 
@@ -31,3 +31,3 @@ from django.views.generic.dates import (
 
from . import frontpage
 
from .feeds import Mp3CastFeed, OggCastFeed, feed_dict, view
 
from .feeds import Mp3CastFeed, OggCastFeed, view
 
from .models import Cast, CastTag
...
 
@@ -62,2 +62,3 @@ if settings.DEBUG:
 

	
 

	
 
def all_tags_by_use_amount():
...
 
@@ -87,2 +88,3 @@ def all_tags_by_use_amount():
 

	
 

	
 
# The functions are passed to the context uncalled so they will be
conservancy/podjango/views.py
Show inline comments
...
 
@@ -23,5 +23,4 @@ from operator import or_
 
from django.shortcuts import get_object_or_404, render
 
from django.views.generic.list import ListView
 

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

	
...
 
@@ -33,2 +32,3 @@ def OR_filter(field_name, objs):
 

	
 

	
 
def last_name(person):
...
 
@@ -36,2 +36,3 @@ def last_name(person):
 

	
 

	
 
def custom_index(request, queryset, *args, **kwargs):
...
 
@@ -77,2 +78,3 @@ def custom_index(request, queryset, *args, **kwargs):
 

	
 

	
 
def query(request):
...
 
@@ -84,6 +86,6 @@ def query(request):
 
        if 'authors' in d.getlist('all'):
 
            d.setlist('author', []) # remove author queries
 
            d.setlist('author', [])  # remove author queries
 
        if 'tags' in d.getlist('all'):
 
            d.setlist('tag', []) # remove tag queries
 
        d.setlist('all', []) # remove "all" from the query string
 
            d.setlist('tag', [])  # remove tag queries
 
        d.setlist('all', [])  # remove "all" from the query string
 

	
...
 
@@ -92,3 +94,3 @@ def query(request):
 
            base_url = '/feeds/cast/'
 
            d.setlist('rss', []) # remove it
 
            d.setlist('rss', [])  # remove it
 

	
...
 
@@ -102,2 +104,3 @@ def query(request):
 

	
 

	
 
def relative_redirect(request, path):
0 comments (0 inline, 0 general)