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

Add newsletter signup example #6

Merged
merged 4 commits into from
May 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove not used code plz

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 removed

# ('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()