Skip to content

Commit

Permalink
Adhésion à l'association via helloasso (#5468)
Browse files Browse the repository at this point in the history
  • Loading branch information
firm1 authored and Situphen committed Oct 9, 2019
1 parent ded5ff9 commit 5e98108
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 163 deletions.
4 changes: 1 addition & 3 deletions templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
<li><a href="{% url "pages-about" %}">{% trans "À propos" %}</a></li>
{% if app.site.association %}
<li><a href="{% url "pages-association" %}">{% trans "L’association" %}</a></li>
{% if user.is_authenticated %}
<li><a href="{% url "pages-assoc-subscribe" %}">{% trans "Adhérer" %}</a></li>
{% endif %}
<li><a href="{{ app.site.association.subscribe_link }}">{% trans "Adhérer à l'association" %}</a></li>
{% endif %}
<li><a href="{% url "pages-contact" %}">{% trans "Contact" %}</a></li>
</ul>
Expand Down
4 changes: 1 addition & 3 deletions templates/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ <h1>{% trans "Pages" %}</h1>
<li><a href="{% url "pages-about" %}">{% trans "À propos" %}</a></li>
{% if app.site.association %}
<li><a href="{% url "pages-association" %}">{% trans "L’association" %}</a></li>
{% if user.is_authenticated %}
<li><a href="{% url "pages-assoc-subscribe" %}">{% trans "Adhérer" %}</a></li>
{% endif %}
<li><a href="{{ app.site.association.subscribe_link }}">{% trans "Adhérer à l'association" %}</a></li>
{% endif %}
<li><a href="{% url "pages-contact" %}">{% trans "Contact" %}</a></li>
<li><a href="{% url "pages-cookies" %}">{% trans "Les cookies" %}</a></li>
Expand Down
68 changes: 0 additions & 68 deletions zds/pages/forms.py

This file was deleted.

28 changes: 0 additions & 28 deletions zds/pages/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.conf import settings
from django.urls import reverse
from django.test import TestCase
from django.test.utils import override_settings
Expand Down Expand Up @@ -66,33 +65,6 @@ def test_url_association(self):

self.assertEqual(result.status_code, 200)

def test_subscribe_association(self):
"""
To test the "subscription to the association" form.
"""
_, forum = create_category_and_forum()

# overrides the settings to avoid 404 if forum does not exist
settings.ZDS_APP['site']['association']['forum_ca_pk'] = forum.pk

# send form
long_str = ''
for i in range(3100):
long_str += 'A'

result = self.client.post(
reverse('pages-assoc-subscribe'),
{
'full_name': 'Anne Onyme',
'email': '[email protected]',
'naissance': '01 janvier 1970',
'adresse': '42 rue du savoir, appartement 42, 75000 Paris, France',
'justification': long_str
},
follow=False)

self.assertEqual(result.status_code, 200)

def test_url_cookies(self):
"""Test: check that cookies page is alive."""

Expand Down
4 changes: 1 addition & 3 deletions zds/pages/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.urls import re_path

from zds.pages.views import about, association, eula, alerts, cookies, index, AssocSubscribeView, \
from zds.pages.views import about, association, eula, alerts, cookies, index, \
ContactView, CommentEditsHistory, EditDetail, restore_edit, delete_edit_content

urlpatterns = [
Expand All @@ -11,8 +11,6 @@
re_path(r'^cgu/$', eula, name='pages-eula'),
re_path(r'^alertes/$', alerts, name='pages-alerts'),
re_path(r'^cookies/$', cookies, name='pages-cookies'),
re_path(r'^association/inscription/$',
AssocSubscribeView.as_view(), name='pages-assoc-subscribe'),
re_path(r'^historique-editions/(?P<comment_pk>\d+)/$',
CommentEditsHistory.as_view(), name='comment-edits-history'),
re_path(r'^contenu-original/(?P<pk>\d+)/$',
Expand Down
52 changes: 1 addition & 51 deletions zds/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,19 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.auth.models import User
from django.urls import reverse
from django.shortcuts import render, get_object_or_404, redirect
from django.template.loader import render_to_string
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView, DetailView
from django.views.generic.edit import FormView
from django.core.exceptions import PermissionDenied
from django.views.decorators.http import require_POST

from zds.featured.models import FeaturedResource, FeaturedMessage
from zds.forum.models import Forum, Topic
from zds.forum.models import Topic
from zds.member.decorator import can_write_and_read_now
from zds.pages.forms import AssocSubscribeForm
from zds.pages.models import GroupContact
from zds.searchv2.forms import SearchForm
from zds.tutorialv2.models.database import PublishableContent, PublishedContent
from zds.utils.forums import create_topic
from zds.utils.models import Alert, CommentEdit, Comment


Expand Down Expand Up @@ -64,50 +58,6 @@ def about(request):
return render(request, 'pages/about.html')


class AssocSubscribeView(FormView):

template_name = 'pages/assoc_subscribe.html'
form_class = AssocSubscribeForm

def form_valid(self, form):
user = self.request.user
data = form.data

site = settings.ZDS_APP['site']

bot = get_object_or_404(User, username=settings.ZDS_APP['member']['bot_account'])
forum = get_object_or_404(Forum, pk=site['association']['forum_ca_pk'])

# create the topic
title = _('Demande d\'adhésion de {}').format(user.username)
subtitle = _('Sujet créé automatiquement pour la demande d\'adhésion à l\'association du membre {} via le form'
'ulaire du site').format(user.username)
context = {
'full_name': data['full_name'],
'email': data['email'],
'birthdate': data['birthdate'],
'address': data['address'],
'justification': data['justification'],
'username': user.username,
'profile_url': site['url'] + reverse('member-detail', kwargs={'user_name': user.username}),

}
text = render_to_string('pages/messages/association_subscribre.md', context)
create_topic(self.request, bot, forum, title, subtitle, text)

messages.success(self.request, _('Votre demande d\'adhésion a bien été envoyée et va être étudiée.'))

return super(AssocSubscribeView, self).form_valid(form)

@method_decorator(login_required)
@method_decorator(can_write_and_read_now)
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)

def get_success_url(self):
return reverse('pages-assoc-subscribe')


def association(request):
"""Display association's presentation."""
return render(request, 'pages/association.html')
Expand Down
11 changes: 4 additions & 7 deletions zds/settings/abstract_base/zds.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
from .config import config
from .base_dir import BASE_DIR


zds_config = config.get('zds', {})


GEOIP_PATH = join(BASE_DIR, 'geodata')


ES_ENABLED = True

ES_CONNECTIONS = {
Expand All @@ -27,11 +24,9 @@
'replicas': 0,
}


# Anonymous [Dis]Likes. Authors of [dis]likes before those pk will never be shown
VOTES_ID_LIMIT = zds_config.get('VOTES_ID_LIMIT', 0)


THUMBNAIL_ALIASES = {
'': {
'avatar': {'size': (60, 60), 'crop': True},
Expand All @@ -52,6 +47,7 @@
},
}

DEFAULT_ASSO_LINK = 'https://www.helloasso.com/associations/zeste-de-savoir/adhesions/zeste-de-savoir-cotisations-2018'

ZDS_APP = {
'site': {
Expand All @@ -77,7 +73,8 @@
'fee': zds_config.get('association_fee', '20 €'),
'email': '[email protected]',
'email_ca': '[email protected]',
'forum_ca_pk': 25
'forum_ca_pk': 25,
'subscribe_link': zds_config.get('association_subscribe_link', DEFAULT_ASSO_LINK)
},
'repository': {
'url': 'https://github.com/zestedesavoir/zds-site',
Expand Down Expand Up @@ -185,7 +182,7 @@
'maximum_slug_size': 150,
'characters_per_minute': 1500,
'editorial_line_link':
'https://zestedesavoir.com/articles/222/la-ligne-editoriale-officielle-de-zeste-de-savoir/',
'https://zestedesavoir.com/articles/222/la-ligne-editoriale-officielle-de-zeste-de-savoir/',
'epub_stylesheets': {
'toc': Path('toc.css'),
'full': Path(BASE_DIR) / 'dist' / 'css' / 'zmd.css',
Expand Down

0 comments on commit 5e98108

Please sign in to comment.