Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Añadir listado de charlas propuestas (Issue #243) #249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion temii/talks/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from django.urls import path
from django.views.generic import TemplateView

from .views import talk_create_view
from .views import talk_create_view, talk_list_view

app_name = "talks"
urlpatterns = [
path("", TemplateView.as_view(template_name="pages/about.html"), name="talks"),
path("~create/", view=talk_create_view, name="create"),
path("thanks/", TemplateView.as_view(template_name="talks/talk_thanks.html"), name="thanks"),
path("~my-talks/", view=talk_list_view, name="list"),
]
13 changes: 12 additions & 1 deletion temii/talks/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.urls import reverse_lazy
from django.views.generic import ListView
from django.views.generic.edit import CreateView

from .forms import NewTalkForm
from .models import Talk


class TalkListView(LoginRequiredMixin, ListView):
"""List all authenticated user talks."""

model = Talk
context_object_name = "talks"
template_name = "talks/list.html"

def get_queryset(self):
return Talk.objects.filter(user=self.request.user)

class TalkCreateView(LoginRequiredMixin, CreateView):
"""Propose a new talk."""

Expand All @@ -18,5 +29,5 @@ def form_valid(self, form):
form.instance.user = self.request.user
return super().form_valid(form)


talk_list_view = TalkListView.as_view()
talk_create_view = TalkCreateView.as_view()
3 changes: 3 additions & 0 deletions temii/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
<li class="nav-item">
<a class="nav-link" href="{% url 'users:detail' request.user.username %}">{% translate "My Profile" %}</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'talks:list' %}">{% translate "My Talks" %}</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'talks:create' %}">{% translate "Propose a talk" %}</a>
</li>
Expand Down
24 changes: 24 additions & 0 deletions temii/templates/talks/talk_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "base.html" %}
{% load i18n %}

{% block title %}My Talks{% endblock %}

{% block content %}

<h2>My Talks</h2>

{% if talks %}
<p>Here you have all the talks you've proposed. </p>
{% endif %}

<ul>
{% for talk in talks %}
<li>Title: {{ talk.name }} - Proposed Month: {{ talk.months }}</li>
{% empty %}
<li>You haven't proposed any talk yet. <a href="{% url 'talks:create' %}">Propose a new one!</a></li>
{% endfor %}
</ul>



{% endblock content %}
Loading