Skip to content

Commit

Permalink
use demo template
Browse files Browse the repository at this point in the history
  • Loading branch information
hidalgopl committed Apr 30, 2021
1 parent 31cad50 commit 2fac827
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/templates/_newsletter_signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<script src="{% static 'sockpuppet/sockpuppet.js' %}"></script>
<h2>Sign up for newsletter!</h2>
<form id="morph-form">
<form id="morph-form" data-reflex-root="#morph">
{{ form }}
<input type="submit" data-reflex="click->Subscription_Reflex#add_person" data-reflex-root="#morph">
<input type="submit" data-reflex="click->Subscription_Reflex#add_person">
<div id="morph">
<h2>Signed:</h2>
<table>
Expand Down
1 change: 1 addition & 0 deletions core/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ <h1 class="leading-none m-0 pl-1 self-center">
<li><a href="{% url 'example' %}">Example</a></li>
<li><a href="{% url 'book_search' %}">BookSearch</a></li>
<li><a href="{% url 'chat' %}">Chat</a></li>
<li><a href="{% url 'newsletter-signup' %}">Newsletter Signup</a> </li>
</ul>
</nav>
</aside>
Expand Down
14 changes: 12 additions & 2 deletions core/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ExampleMixin(MixinBase):
('core/templates/_example_demo.html', 'html', 'htmldjango'),
)


class ChatMixin(MixinBase):
files = (
('core/views/chat.py', 'python', 'python3'),
Expand All @@ -59,12 +60,21 @@ class ChatMixin(MixinBase):
('core/templates/_chat_demo.html', 'html', 'htmldjango'),
)


class CalendarMixin(MixinBase):
files = (
('core/views/calendar.py', 'python', 'python3'),
# ('core/reflexes/calendar_reflex.py', 'python', 'python3'),
# ('core/javascript/controllers/calendar_controller.js', 'javascript', 'javascript'),
# ('core/reflexes/calendar_reflex.py', 'python', 'python3'),
# ('core/javascript/controllers/calendar_controller.js', 'javascript', 'javascript'),
('core/templates/_calendar.html', 'html', 'htmldjango'),
('core/templates/_td_calendar.html', 'html', 'htmldjango'),

)


class NewsletterSignupMixin(MixinBase):
files = (
('core/views/newsletter_signup.py', 'python', 'python3'),
('core/reflexes/newsletter_signup_reflex.py', 'python', 'python3'),
('core/templates/_newsletter_signup.html', 'html', 'htmldjango')
)
8 changes: 5 additions & 3 deletions core/views/newsletter_signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.views.generic.edit import FormView

from core.models import NewsletterSubscription
from core.views.mixins import NewsletterSignupMixin


class NewsletterSubscriptionForm(ModelForm):
Expand All @@ -10,14 +11,15 @@ class Meta:
fields = ['name', 'email']


class YourReflexNameView(FormView):
template_name = '_newsletter_signup.html'
class NewsletterSignupView(NewsletterSignupMixin, FormView):
demo_template = '_newsletter_signup.html'
form_class = NewsletterSubscriptionForm
subtitle = 'Newsletter Signup'

def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['people'] = NewsletterSubscription.objects.all()
return context


view = YourReflexNameView.as_view()
view = NewsletterSignupView.as_view()

0 comments on commit 2fac827

Please sign in to comment.