diff --git a/audio/episode_views.py b/audio/episode_views.py
index 38c549d..6b452df 100644
--- a/audio/episode_views.py
+++ b/audio/episode_views.py
@@ -1,19 +1,26 @@
from django.shortcuts import render, redirect
from .forms import EpisodeForm
-from .models import Feed, Episode
+from .models import Feed, Episode, rand_slug
+from django.utils.text import slugify
def edit_episode(request, pk, title_slug):
if not request.user.is_authenticated:
return redirect('audio:home')
+ slug = title_slug
episode = Episode.objects.get(id=pk)
+ otitle = episode.title
if not episode.user == request.user:
return redirect('audio:home')
if request.method == "POST":
form = EpisodeForm(request.POST, request.FILES, instance=episode)
if form.is_valid():
- form.save()
- return redirect('audio:episode', pk=pk, slug=title_slug)
+ nepisode = form.save(commit=False)
+ if nepisode.title != otitle:
+ nepisode.slug = slugify(rand_slug() + "-" + nepisode.title)
+ slug = nepisode.slug
+ nepisode.save()
+ return redirect('audio:episode', pk=pk, slug=slug)
else:
form = EpisodeForm(instance=episode)
return render(
diff --git a/audio/templates/audio/index.html b/audio/templates/audio/index.html
index b6b6198..799de4a 100644
--- a/audio/templates/audio/index.html
+++ b/audio/templates/audio/index.html
@@ -66,6 +66,11 @@
{% endfor %}
+ {% if is_episode %}
+
-
- {{ j.title }}
-
-
{{ j.title }}
-
- {{ j.pub_date }}
-
-
- {{ j.description }}
-
-
-
-
-
RSS
-
- {% if user.is_authenticated %}
- {% if user == j.user %}
-
- {% endif %}
- {% endif %}
-
- {% endfor %}
diff --git a/audio/views.py b/audio/views.py
index ecd61ba..18529f6 100644
--- a/audio/views.py
+++ b/audio/views.py
@@ -1,7 +1,8 @@
from django.shortcuts import render, redirect, reverse
from django.contrib.sites.shortcuts import get_current_site
from .forms import FeedForm
-from .models import Feed, Episode
+from django.utils.text import slugify
+from .models import Feed, Episode, rand_slug
from tp.settings import IMAGES_URL, MP3_URL
@@ -34,7 +35,7 @@ def episode(request, pk, slug):
{
'episodes': (episode, ), 'IMAGES_URL': IMAGES_URL, 'is_episode': True,
'MP3_URL': MP3_URL, 'title': episode.title, 'heading': episode.title,
- 'ogtitle': episode.title, 'ogurl': og_url, 'ogmp3': episode.mp3
+ 'ogtitle': episode.title, 'ogurl': og_url, 'ogmp3': episode.mp3, 'feed': episode.feed
})
@@ -64,14 +65,20 @@ def new_feed(request):
def edit_feed(request, pk, title_slug):
if not request.user.is_authenticated:
return redirect('audio:home')
+ slug = title_slug
feed = Feed.objects.get(id=pk)
+ otitle = feed.title
if not feed.user == request.user:
return redirect('audio:home')
if request.method == "POST":
form = FeedForm(request.POST, request.FILES, instance=feed)
if form.is_valid():
- feed.save()
- return redirect('audio:feed', pk=pk, slug=title_slug)
+ nfeed = form.save(commit=False)
+ if nfeed.title != otitle:
+ nfeed.slug = slugify(rand_slug() + "-" + nfeed.title)
+ slug = nfeed.slug
+ nfeed.save()
+ return redirect('audio:feed', pk=pk, slug=slug)
else:
form = FeedForm(instance=feed)
return render(