Changeset - acd2cef27674
[Not reviewed]
10 4 7
Ben Sturmfels (bsturmfels) - 6 months ago 2023-10-19 06:21:53
ben@sturm.com.au
Merge podjango.apps.cast into main podjango module

It's much simpler if "podjango" is the name of the Django app with a single
urls.py etc. The reason this is required is because podjango was originally a
fully-blown Django website and now it's become a Django app within the
Conservancy website.
14 files changed with 59 insertions and 98 deletions:
0 comments (0 inline, 0 general)
www/conservancy/settings.py
Show inline comments
...
 
@@ -97,8 +97,7 @@ INSTALLED_APPS = [
 
    'conservancy.apps.fundgoal',
 
    'conservancy.apps.assignment',
 
    'conservancy.apps.fossy',
 
    'podjango',  # Here so that the templates are found
 
    'podjango.apps.cast',
 
    'podjango',
 
]
 

	
 
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
www/podjango/admin.py
Show inline comments
 
file renamed from www/podjango/apps/cast/admin.py to www/podjango/admin.py
www/podjango/apps/cast/migrations/__init__.py
Show inline comments
 
deleted file
www/podjango/apps/cast/templatetags/__init__.py
Show inline comments
 
deleted file
www/podjango/apps/cast/urls.py
Show inline comments
 
deleted file
www/podjango/feeds.py
Show inline comments
...
 
@@ -17,18 +17,17 @@
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 
from datetime import datetime
 
import itertools
 
import operator
 

	
 
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 podjango.apps.staff.models import Person
 
from podjango.apps.cast.models import Cast
 

	
 
from django.shortcuts import render
 
from django.conf import settings
 
from datetime import datetime
 

	
 
import itertools
 
import operator
 
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
...
 
@@ -18,9 +18,10 @@
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 

	
 
from django.shortcuts import render
 
from podjango.apps.cast.models import Cast
 
from datetime import datetime, timedelta
 

	
 
from .models import Cast
 

	
 
def view(request):
 
    """Cast front page view
 
    Performs all object queries necessary to render the front page.
www/podjango/migrations/0001_initial.py
Show inline comments
 
file renamed from www/podjango/apps/cast/migrations/0001_initial.py to www/podjango/migrations/0001_initial.py
www/podjango/migrations/__init__.py
Show inline comments
 
file renamed from www/podjango/apps/__init__.py to www/podjango/migrations/__init__.py
www/podjango/models.py
Show inline comments
 
file renamed from www/podjango/apps/cast/models.py to www/podjango/models.py
www/podjango/templatetags/__init__.py
Show inline comments
 
file renamed from www/podjango/apps/cast/__init__.py to www/podjango/templatetags/__init__.py
www/podjango/templatetags/date_within.py
Show inline comments
 
file renamed from www/podjango/apps/cast/templatetags/date_within.py to www/podjango/templatetags/date_within.py
www/podjango/urls.py
Show inline comments
...
 
@@ -21,18 +21,31 @@ from django.conf import settings
 
from django.conf.urls import url, include
 
from django.contrib import admin
 
from django.contrib.syndication.views import Feed
 
from django.views.generic.dates import DateDetailView, DayArchiveView, MonthArchiveView, YearArchiveView
 

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

	
 
#handler404 = 'modpythoncustom.view404'
 
app_name = 'podjango'
 

	
 
admin.autodiscover()
 
extra_context = {}
 
info_dict = {
 
    'queryset': Cast.objects.all(),
 
    'date_field': 'pub_date',
 
    'extra_context': extra_context,
 
    'template_name': 'podjango/cast/cast_detail.html',
 
}
 

	
 
app_name = 'podjango'
 
urlpatterns = [
 
    url(r'^$', frontpage.view),
 
    url(r'', include('podjango.apps.cast.urls')),
 
    url(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$', DateDetailView.as_view(**info_dict), name='detail'),
 
    url(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', DayArchiveView.as_view(**info_dict), name='day-archive'),
 
    url(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', MonthArchiveView.as_view(**info_dict), name='month-archive'),
 
    url(r'^(?P<year>\d{4})/$', YearArchiveView.as_view(**info_dict), name='year-archive'),
 
    url(r'^all/$', custom_index, dict(info_dict, paginate_by=20), name='cast'),
 
    url(r'^query/$', query, name='query'),
 
    url(r'^feeds/cast-ogg/$', OggCastFeed(), name='feed-ogg'),
 
    url(r'^feeds/cast-mp3/$', Mp3CastFeed(), name='feed-mp3'),
 
    url(r'^feeds/$', view, name='feeds'),
...
 
@@ -41,3 +54,35 @@ urlpatterns = [
 
if settings.DEBUG:
 
  from django.conf.urls.static import static
 
  urlpatterns += static('/', document_root='podjango/static')
 

	
 
def all_tags_by_use_amount():
 
    """Returns all tags with an added 'cnt' attribute (how many times used)
 

	
 
    Also sorts the tags so most-used tags appear first.
 
    """
 

	
 
    # tally use amount
 
    retval = []
 
    current = None
 
    for obj in CastTag.objects.filter(cast__pub_date__lte=datetime.now(),
 
                                      cast__isnull=False).order_by('label'):
 
        if current is not None and obj.id == current.id:
 
            current.cnt += 1
 
        else:
 
            if current is not None:
 
                retval.append(current)
 
            current = obj
 
            current.cnt = 1
 
    if current is not None:
 
        retval.append(current)
 

	
 
    # sort and return
 
    retval.sort(key=lambda x: -x.cnt)
 
    return retval
 

	
 
# The functions are passed to the context uncalled so they will be
 
# called for each web request.  If we want to only make these database
 
# queries a single time when a web server process begins, call both
 
# functions below (i.e. make both lines below end in '()')
 

	
 
extra_context['all_tags'] = all_tags_by_use_amount
www/podjango/views.py
Show inline comments
 
file renamed from www/podjango/apps/cast/views.py to www/podjango/views.py
0 comments (0 inline, 0 general)