add +1 mechanism (#19000)
This commit is contained in:
parent
1939be722f
commit
4e614aa6f8
|
@ -27,5 +27,8 @@ class AppConfig(django.apps.AppConfig):
|
|||
name = __name__
|
||||
verbose_name = _('GNM Extension')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
return urls.urlpatterns
|
||||
|
||||
default_app_config = __name__ + '.AppConfig'
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# combo-plugin-gnm - Combo GNM plugin
|
||||
# Copyright (C) 2017 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^gnm/plusone/$', views.plusone, name='gnm-plus-one'),
|
||||
]
|
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# combo-plugin-gnm - Combo GNM plugin
|
||||
# Copyright (C) 2017 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.template import RequestContext
|
||||
|
||||
from combo.utils import requests, get_templated_url
|
||||
|
||||
def plusone(request, *args, **kwargs):
|
||||
# add reference to a jsondatastore with slug "plus1"
|
||||
reference = request.GET.get('ref')
|
||||
if reference:
|
||||
context = RequestContext(request, {'request': request})
|
||||
passerelle_url = '[passerelle_url]jsondatastore/plus1/data/create'
|
||||
if request.user and request.user.is_authenticated():
|
||||
passerelle_url += '?name_id=[user_nameid]'
|
||||
passerelle_url = get_templated_url(passerelle_url, context)
|
||||
headers = {'content-type': 'application/json'}
|
||||
requests.post(passerelle_url, remote_service='auto',
|
||||
without_user=True,
|
||||
headers={'Accept': 'application/json'},
|
||||
json={'reference': reference},
|
||||
timeout=2)
|
||||
|
||||
messages.info(request, u'Merci, votre confirmation nous est utile.')
|
||||
if request.user and request.user.is_authenticated():
|
||||
return HttpResponseRedirect('/')
|
||||
else:
|
||||
return HttpResponseRedirect('/services/')
|
Loading…
Reference in New Issue