Skip to content

Commit

Permalink
fix all views and urls and templates
Browse files Browse the repository at this point in the history
  • Loading branch information
mnamaki committed Dec 17, 2020
1 parent 3fee947 commit abdfd6f
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 116 deletions.
9 changes: 3 additions & 6 deletions content/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
path('blog/', views.Blog.as_view(), name='blog'),
path('blog/<int:pk>/', views.BlogArchiveByCategoryPK.as_view(), name='blog_archive_by_category_pk'),
path('blog/<str:slug>/', views.BlogSingle.as_view(), name='blog_single'),
path('blog/<int:pk>/<str:slug>/', views.BlogSingle.as_view(), name='blog_single'),
path('videocast/', views.VideoCast.as_view(), name='videocast'),
path('videocast/<int:pk>/', views.VideoCastArchiveByCategoryPK.as_view(), name='videocast_archive_by_category_pk'),
path('videocast/<str:slug>/', views.VideoCastSingle.as_view(), name='videocast_single'),
path('videocast/<int:pk>/<str:slug>/', views.VideoCastSingle.as_view(), name='videocast_single'),
path('video_cast/', views.VideoCast.as_view(), name='video_cast'),
path('video_cast/<int:pk>/', views.VideoCastArchiveByCategoryPK.as_view(), name='video_cast_archive_by_category_pk'),
path('video_cast/<str:slug>/', views.VideoCastSingle.as_view(), name='video_cast_single'),
path('podcast/', views.Podcast.as_view(), name='podcast'),
path('podcast/<int:pk>/', views.PodArchiveByCategoryPK.as_view(), name='podcast_archive_by_category_pk'),
path('podcast/<str:slug>/', views.PodSingle.as_view(), name='podcast_single'),
path('podcast/<int:pk>/<str:slug>/', views.PodSingle.as_view(), name='podcast_single'),
]
91 changes: 34 additions & 57 deletions content/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,85 +45,62 @@ def get(self, request, *args, **kwargs):

class Blog(generic.ListView):
model = models.Blog
template_name = 'archive.html'
context_object_name = 'archives'
template_name = 'blog_archive.html'


class BlogArchiveByCategoryPK(View):
template_name = 'archive.html'
class BlogArchiveByCategoryPK(generic.ListView):
model = models.Blog
template_name = 'blog_archive.html'

def get(self, request, *args, **kwargs):
context = {
'archives': models.Blog.objects.filter(category=self.kwargs['pk']),
}
return render(request, self.template_name, context)
def get_queryset(self):
return self.model.objects.filter(category=self.kwargs['pk'])


class BlogSingle(View):
class BlogSingle(generic.DetailView):
model = models.Blog
template_name = 'single.html'

def get(self, request, *args, **kwargs):
context = {
'single_content': models.Blog.objects.filter(slug=self.kwargs['slug']),
}
return render(request, self.template_name, context)

def get_queryset(self):
return self.model.objects.filter(slug=self.kwargs['slug'])

class VideoCast(View):
template_name = 'archive.html'

def get(self, request, *args, **kwargs):
context = {
'archives': models.VideoCast.objects.all(),
}
return render(request, self.template_name, context)
class VideoCast(generic.ListView):
model = models.VideoCast
template_name = 'video_cast_archive.html'


class VideoCastArchiveByCategoryPK(View):
template_name = 'archive.html'
class VideoCastArchiveByCategoryPK(generic.ListView):
model = models.VideoCast
template_name = 'video_cast_archive.html'

def get(self, request, *args, **kwargs):
context = {
'archives': models.VideoCast.objects.filter(category=self.kwargs['pk']),
}
return render(request, self.template_name, context)
def get_queryset(self):
return self.model.objects.filter(category=self.kwargs['pk'])


class VideoCastSingle(View):
class VideoCastSingle(generic.DetailView):
model = models.VideoCast
template_name = 'single.html'

def get(self, request, *args, **kwargs):
context = {
'single_content': models.VideoCast.objects.filter(slug=self.kwargs['slug']),
}
return render(request, self.template_name, context)
def get_queryset(self):
return self.model.objects.filter(slug=self.kwargs['slug'])


class Podcast(View):
template_name = 'archive.html'

def get(self, request, *args, **kwargs):
context = {
'archives': models.Podcast.objects.all(),
}
return render(request, self.template_name, context)
class Podcast(generic.ListView):
model = models.Podcast
template_name = 'podcast_archive.html'


class PodArchiveByCategoryPK(View):
template_name = 'archive.html'
class PodArchiveByCategoryPK(generic.ListView):
model = models.Podcast
template_name = 'podcast_archive.html'

def get(self, request, *args, **kwargs):
context = {
'archives': models.Podcast.objects.filter(category=self.kwargs['pk']),
}
return render(request, self.template_name, context)
def get_queryset(self):
return self.model.objects.filter(category=self.kwargs['pk'])


class PodSingle(View):
class PodSingle(generic.DetailView):
model = models.Podcast
template_name = 'single.html'

def get(self, request, *args, **kwargs):
context = {
'single_content': models.Podcast.objects.filter(slug=self.kwargs['slug']),
}
return render(request, self.template_name, context)
def get_queryset(self):
return self.model.objects.filter(slug=self.kwargs['slug'])
37 changes: 0 additions & 37 deletions templates/archive.html

This file was deleted.

4 changes: 2 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ <h2>Menu</h2>
{% endfor %}
</ul>
</li>
<li><a href="{% url 'content:videocast' %}">{% translate 'Video Cast' %}</a></li>
<li><a href="{% url 'content:video_cast' %}">{% translate 'Video Cast' %}</a></li>
<li>
<span class="opener">{% translate 'Video Cast Categories' %}</span>
<ul>
{% for video_cast_category in video_cast_categories %}
<li><a href="{% url 'content:videocast_archive_by_category_pk' video_cast_category.pk %}">{{ video_cast_category.title }}</a></li>
<li><a href="{% url 'content:video_cast_archive_by_category_pk' video_cast_category.pk %}">{{ video_cast_category.title }}</a></li>
{% endfor %}
</ul>
</li>
Expand Down
4 changes: 2 additions & 2 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ <h2>{% translate 'The latest Video Casts' %}</h2>
<div class="posts">
{% for video_cast in video_casts %}
<article>
<a href="{% url 'content:videocast_single' video_cast.slug %}" class="image" title="{{ video_cast.title }}">
<a href="{% url 'content:video_cast_single' video_cast.slug %}" class="image" title="{{ video_cast.title }}">
<img src="{{ video_cast.thumbnail.url }}" alt="{{ video_cast.title }}"/>
</a>
<h3>{{ video_cast.title }}</h3>
<p>{{ video_cast.content | safe | truncatewords_html:30 }}</p>
<ul class="actions">
<li>
<a href="{% url 'content:videocast_single' video_cast.slug %}" class="button" title="{{ video_cast.title }}">{% translate 'More' %}</a>
<a href="{% url 'content:video_cast_single' video_cast.slug %}" class="button" title="{{ video_cast.title }}">{% translate 'More' %}</a>
</li>
</ul>
</article>
Expand Down
32 changes: 32 additions & 0 deletions templates/podcast_archive.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% extends 'base.html' %}
{% load i18n %}

{% block content %}
<!-- Section - archive -->
<section id="archive">
<header class="major">
<h2>
{% translate 'Podcast Archive' %}
</h2>
</header>
<div class="posts">
{% for object in object_list %}
<article>
<a href="{% url 'content:podcast_single' object.slug %}" class="image" title="{{ object.title }}">
<img src="{{ object.thumbnail.url }}" alt="{{ object.title }}"/>
</a>
<h3>{{ object.title }}</h3>
<p>{{ object.content | safe | truncatewords_html:30 }}</p>
<ul class="actions">
<li>
<a href="{% url 'content:podcast_single' object.slug %}" class="button" title="{{ object.title }}">
{% translate 'More' %}
</a>
</li>
</ul>
</article>
{% endfor %}
</div>
</section>
<!-- /Section - archive -->
{% endblock %}
2 changes: 1 addition & 1 deletion templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h3>{{ blog.title }}</h3>

{% for videocast in videocasts %}
<article>
<a href="{% url 'content:videocast_single' videocast.slug %}" title="{{ videocast.title }}">
<a href="{% url 'content:video_cast_single' videocast.slug %}" title="{{ videocast.title }}">
<h3>{{ videocast.title }}</h3>
</a>
<p>{{ videocast.content | safe | truncatewords_html:10 }}</p>
Expand Down
17 changes: 8 additions & 9 deletions templates/single.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
{% extends 'base.html' %}
{% load i18n %}

{% block content %}
{% for single in single_content %}
<!-- Content -->
<section>
<header class="main">
<h1>{{ single.title }}</h1>
<h1>{{ object.title }}</h1>
</header>

<span class="image main">
<img src="{{ single.thumbnail.url }}" alt="{{ single.title }}"/>
<img src="{{ object.thumbnail.url }}" alt="{{ object.title }}"/>
</span>

{{ single.content | safe }}
{{ object.content | safe }}

{% if single.video %}
<a href="{{ single.video }}" class="button primary fit icon solid fa-video">Show Video</a>
{% if object.video %}
<a href="{{ object.video }}" class="button primary fit icon solid fa-video">{% translate 'Show Video' %}</a>
{% endif %}

{% if single.audio %}
<a href="{{ single.audio.url }}" class="button primary fit icon solid fa-download">Download Audio</a>
{% if object.audio %}
<a href="{{ object.audio.url }}" class="button primary fit icon solid fa-download">{% translate 'Download Audio' %}</a>
{% endif %}

</section>
<!-- /Content -->
{% endfor %}
{% endblock %}
4 changes: 2 additions & 2 deletions templates/video_cast_archive.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ <h2>
<div class="posts">
{% for object in object_list %}
<article>
<a href="{% url 'content:videocast_single' object.slug %}" class="image" title="{{ object.title }}">
<a href="{% url 'content:video_cast_single' object.slug %}" class="image" title="{{ object.title }}">
<img src="{{ object.thumbnail.url }}" alt="{{ object.title }}"/>
</a>
<h3>{{ object.title }}</h3>
<p>{{ object.content | safe | truncatewords_html:30 }}</p>
<ul class="actions">
<li>
<a href="{% url 'content:videocast_single' object.slug %}" class="button" title="{{ object.title }}">
<a href="{% url 'content:video_cast_single' object.slug %}" class="button" title="{{ object.title }}">
{% translate 'More' %}
</a>
</li>
Expand Down

0 comments on commit abdfd6f

Please sign in to comment.