From b09698e8599242721d3176129ff57a64b88b8d80 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 30 Oct 2017 12:47:48 +0200 Subject: [PATCH] Implement kaehmy export table --- .gitignore | 1 + locale/en/LC_MESSAGES/django.mo | Bin 9813 -> 9781 bytes locale/en/LC_MESSAGES/django.po | 43 ++++++---- locale/fi/LC_MESSAGES/django.mo | Bin 14849 -> 14956 bytes locale/fi/LC_MESSAGES/django.po | 51 ++++++----- webapp/models.py | 9 ++ webapp/tables.py | 14 ++- webapp/templates/kaehmy_base.html | 7 ++ webapp/templates/kaehmy_error.html | 2 +- webapp/templates/kaehmy_export.html | 17 ++++ webapp/urls.py | 2 + webapp/views.py | 128 ++++++++++++++++------------ 12 files changed, 176 insertions(+), 98 deletions(-) create mode 100644 webapp/templates/kaehmy_export.html diff --git a/.gitignore b/.gitignore index 9d57179..d765d1f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ requirements_henu.txt /collected_static/ mydatabase settings.json +.vscode/ \ No newline at end of file diff --git a/locale/en/LC_MESSAGES/django.mo b/locale/en/LC_MESSAGES/django.mo index 87e21ae6bd60ea527ac0ea80617ec689cf2bcf7e..1df24975e4c3e04fe8f47dbec8d258cbe11545ec 100644 GIT binary patch delta 2817 zcmXxke@vBC9LMnkB607<5cwhU<8tw;DO^B6B$qZ1 z$RV>3Jy?!0xN5ZTmgSJG))YupN7hLGTw&) zEW}xMyaE06H=q{}VY+dQ`6SdZ<`Pcgzz8bySkhFcsr>0i0o26Bs2i5r{u0#6A44Tv ziKbyqOf|^hjXh)sbgJZeBd4q-~KB56Uj^toYpeFvp_P<6=^dlzWRn&ENPzgtJ zP&bZ6&6A9p$A>d97nflbs-o|qqZ2RF&;&!6fy1`%i8UsHej;k(08Yn3R7KWcXoaZK zH=&-1t#;f&ax*)v2l0BCG5x3tbjMMDo$y*5`-I0)2@Rnp`~!948@4}U4U1=$jC)WM zrCBpki4~zL_b{qLWyqRLg+2bXJ>DEo{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A^eE=<99Fkl>3=QfPFjFb2wmh_Z)8YgY>nTDDt8?$jPhOik`(G%$C#49v3!F5c-o3@`k)|d(OGf)#3Vdh>cmAj8SCutZRnQR+Koz} z4|SurZ2u^#A|In}bQ)EOLF>1uc`l+Jweu4Vch@t^eGH^wDpsIYve3V9@P?5g;t_Z?|&-|J$uI;Fs28U@gCHQ zj#y8iEcmabrg7Ro(`KW{+wEYTHVpXUL)nEbE+wonPuJ?Z*4VC0G4B)WU!v@f! zNke5`gi5p=b)y>8#0{tf*4lmxYUP_y3Ady6!cNqAyHN|RXNJJ%&g32@(wFgR27cRvNY(TBN8=u5usFhD7Yh5=P*`Fqeyy2!2c_Yno)I4og zr=5mYv>jEFUfbV~s>or~1t(F7owmP!hpND^^=DK9H&8daW&7i%L@JSpy3Z8ULW2<< zlTSkv6(PkiWvCT5qCQ9+n2K+sR&*A5LChuF_i&Q>lTi~Fq7r@xRpLri1?o_bs0Fo< zPK+`0jd_EHZnzhf;YX#HDOZ;6$@GQ+7qMT?U?i{OWyc+(+JH2u{t$HGl zU<xjjKa(;}cB5H^(qL8?A6w~MkuZRm&ucxI=(`$cv6xZ5zt#u2oAXJ$p z#603DLhn5WwJ zUg1k9c;4+tc4Ucd&%n*ZPNLC{wc!RLhUf_&_9c5?p`}m6%i%#^;;1#WbSxyE?*H94 sAue`)^ZM26np(q+>2nU2_@hVWK9HJ|Uzj($KQt-j|6ltX(}$w|17RQsg8%>k diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po index 938639e..2b168e8 100644 --- a/locale/en/LC_MESSAGES/django.po +++ b/locale/en/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-10-28 14:37+0100\n" +"POT-Creation-Date: 2017-10-30 11:39+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -247,10 +247,6 @@ msgstr "Last paid" msgid "Edit" msgstr "Edit" -#: .\members\tables.py:20 .\members\tables.py:39 .\members\tables.py:56 -msgid "Options" -msgstr "Options" - #: .\members\templates\application_delete_confirm.html:9 #, fuzzy #| msgid "Are you sure you want to delete this payment?" @@ -788,7 +784,7 @@ msgstr "Kaehmy application" msgid "Kaehmylomakkeet" msgstr "Kaehmy applications" -#: .\webapp\models.py:185 .\webapp\models.py:258 +#: .\webapp\models.py:185 .\webapp\models.py:267 msgid "Phone number" msgstr "" @@ -818,38 +814,42 @@ msgstr "" msgid "Official: {}" msgstr "" -#: .\webapp\models.py:241 +#: .\webapp\models.py:250 msgid "Role" msgstr "" -#: .\webapp\models.py:242 +#: .\webapp\models.py:251 .\webapp\tables.py:16 msgid "Roles" msgstr "" -#: .\webapp\models.py:244 +#: .\webapp\models.py:253 msgid "Start date" msgstr "" -#: .\webapp\models.py:245 +#: .\webapp\models.py:254 msgid "End date" msgstr "" -#: .\webapp\models.py:255 +#: .\webapp\models.py:264 msgid "Official" msgstr "" -#: .\webapp\models.py:256 +#: .\webapp\models.py:265 msgid "Officials" msgstr "" -#: .\webapp\models.py:284 +#: .\webapp\models.py:293 msgid "Telegram channel" msgstr "" -#: .\webapp\models.py:285 +#: .\webapp\models.py:294 msgid "Telegram channels" msgstr "" +#: .\webapp\tables.py:17 +msgid "Applied for board" +msgstr "" + #: .\webapp\templates\admin_index.html:6 msgid "SIK Admin" msgstr "SIK Admin" @@ -932,6 +932,16 @@ msgstr "Deadline to apply as a non-board official!" msgid "Vaalikokous, osa 3 (toimarien valinta)" msgstr "Election meeting, part 3 (non-board election)" +#: .\webapp\templates\kaehmy_export.html:9 +#, fuzzy +#| msgid "Applications" +msgid "All applications" +msgstr "Applications" + +#: .\webapp\templates\kaehmy_export.html:14 +msgid "Front page" +msgstr "" + #: .\webapp\templates\kaehmy_list.html:24 #: .\webapp\templates\kaehmy_list.html:59 msgid "All kaehmys" @@ -1027,4 +1037,7 @@ msgstr "All challenges" #: .\webapp\templates\ohlhafv_list.html:15 msgid "Total challenges:" -msgstr "Total challenges:" \ No newline at end of file +msgstr "Total challenges:" + +#~ msgid "Options" +#~ msgstr "Options" diff --git a/locale/fi/LC_MESSAGES/django.mo b/locale/fi/LC_MESSAGES/django.mo index 4769e3e257032e92837c277117cca32600134433..8ebd2967caa4a7855c2461c924ce0f193ef45f38 100644 GIT binary patch delta 5096 zcmYk;2Y8j$9mnyLNeBdxBp^e$j0{KuiR@WMkq`tCgdoZYBtS|A4L2wdxCInTDJVn{ zXeg9bR;zMFWDltfDYaNZMpZ_Y)ne0@J}m|P{__6q!~6K-bI!T%J@b8Uoa?{s4}4xX z{0+x-jWj0Rt2x&$#JT5dsnxmUSm*Mv6&}M^F$%NeJjY=e^?XdhLX5 ziia=_|BB(*sGf5%jPHCD^u;z<9lKS1;9Nh{jl=Bok*JmDp;l0Yx_<_;X>LC9pIgK~ zkKsCNKZG5qA4lE)05!p=`p&greAkdd6YPmv$!K#nHlV&5HQ+AP4jsW5JcAneOY=I` zrTz_aN-peCZ>Q>G8|ulZg=V7`mWu%u@+qjJBGlPUM{V_N)E5?_R=yl{{~FX0Y(U+& z6LsHVR6nON0?(o*bP4<89aKM^Se5SU)qwrijhQsa!Kkx-2DMcaP!lRd4d}PeU$*+| zNS|&aYGMaa1AKt$?-Z)PGpGSCqjvHJ>b`$AVE@%{pN3G3YUq8j2I`BCU^@CR3!lbR ztiS|3f!gXjr~$(odHq$#X4K=X-Vu53TyNCC*_e#u0u*$X3y}xjy@^`McGM2MgL=L8 zTKhrd`Ef^4&%#CX7JkiZdk=LKS9t>U`8U`e^?+%D9Z>ytLro;m&l(1sBT-N1cvMGz zb1rJ4OHfBrf!fmbsH53tpYKBrbP{#n$EY1ThisC&g_>9-Pdb|(aP=stqjb~`bhi2+ zOr$;>n`0TSz%{5H>g@Bjx(BjomxO;O)ZMIBuS)CBvYzL$*wJ^f=S z$b8g{{dPkcYT)_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+K>|E4qScUqAT#ahC(@&u{g&NcVT%k8Z zAL@fi*cu-|J+-}2zmCtLmij-aJ-&-t>R6_!ujXu2`$sVjC!*Swqb62~S^@tGE389x z_y%eqTQM|3yIy1UhoQEp1hpkEVd!DQC#hGVW_${h@JsV1s-5p) zCZ`{X#uU_19_HX9sF6>`EL?>ez&_Mc9!71=3DkhknAb3z`d#ELbiXD#wvt|<62B+r z9#6kpOF^SuY!}2EWH`~P{E0k6bo`18BhM18oQ~fT?Kk%feJPDV9X}>xi6)>oY%}RY zQV9zXT7g#TetZnkl|-c7Ng z$s#-V{{2~~u01?&7la;?Us(O8xSGV1?~pd+HNrP>=xNq=eUE%VmXmkM1o9HmQA3)O z7ge!?7sUC;@$b*1niP=sWHKos>Es}(e-u%fPY#hCP(u35Iw@ES41G|6>BszlRE%KQv zcC^<152cbvo+f%twi6w>WCdAC9wYsTj*A}dxY-j&k#l4Vd7kJP?ct7L7xEGLm=qEn zpO8xJzh0@iWB{okyU1_Iqhut}55{|B4(U&3li!nY@*{GAJV?GIIwq1?WIE|Uen@oq zJlyZ_1o(vs-tN`6jWCMSuGGbB1x;+GPKkT|O+4Dvep1IZzu5*=TVZJ`oF z?M$IXsN(&rs#iW@<-}m?rhf?wq$E!a97=8*3?>&x24h<6YS3U>*`%pcW(4=9Cq%_` z?w(%IrAJ}6z$cmcfsCvbfqR*4g2AkNVSz*0F9wU+pNtH)%>7pbU*8!M%E~A6FBt#O H=&1hzRZZb6 diff --git a/locale/fi/LC_MESSAGES/django.po b/locale/fi/LC_MESSAGES/django.po index 0e8961c..34433c8 100644 --- a/locale/fi/LC_MESSAGES/django.po +++ b/locale/fi/LC_MESSAGES/django.po @@ -7,15 +7,15 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-10-28 14:37+0100\n" +"POT-Creation-Date: 2017-10-30 11:39+0100\n" "PO-Revision-Date: 2017-10-29 11:57+0200\n" +"Last-Translator: \n" +"Language-Team: \n" "Language: fi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"Last-Translator: \n" -"Language-Team: \n" "X-Generator: Poedit 2.0.4\n" #: .\infoscreen\models.py:97 @@ -248,10 +248,6 @@ msgstr "Viimeksi maksettu" msgid "Edit" msgstr "Muokkaa" -#: .\members\tables.py:20 .\members\tables.py:39 .\members\tables.py:56 -msgid "Options" -msgstr "Asetukset" - #: .\members\templates\application_delete_confirm.html:9 msgid "Are you sure you want to delete this application?" msgstr "Oletko varma, että haluat poistaa tämän hakemuksen?" @@ -771,7 +767,7 @@ msgstr "Kaehmylomake" msgid "Kaehmylomakkeet" msgstr "Kaehmylomakkeet" -#: .\webapp\models.py:185 .\webapp\models.py:258 +#: .\webapp\models.py:185 .\webapp\models.py:267 msgid "Phone number" msgstr "Puhelinnumero" @@ -799,38 +795,42 @@ msgstr "Hallitus: {}" msgid "Official: {}" msgstr "Toimari: {}" -#: .\webapp\models.py:241 +#: .\webapp\models.py:250 msgid "Role" msgstr "Rooli" -#: .\webapp\models.py:242 +#: .\webapp\models.py:251 .\webapp\tables.py:16 msgid "Roles" msgstr "Roolit" -#: .\webapp\models.py:244 +#: .\webapp\models.py:253 msgid "Start date" msgstr "Alkupäivämäärä" -#: .\webapp\models.py:245 +#: .\webapp\models.py:254 msgid "End date" msgstr "Loppupäivämäärä" -#: .\webapp\models.py:255 +#: .\webapp\models.py:264 msgid "Official" msgstr "Toimihenkilö" -#: .\webapp\models.py:256 +#: .\webapp\models.py:265 msgid "Officials" msgstr "Toimihenkilöt" -#: .\webapp\models.py:284 +#: .\webapp\models.py:293 msgid "Telegram channel" msgstr "Telegram-kanava" -#: .\webapp\models.py:285 +#: .\webapp\models.py:294 msgid "Telegram channels" msgstr "Telegram-kanavat" +#: .\webapp\tables.py:17 +msgid "Applied for board" +msgstr "Hakenut hallitukseen" + #: .\webapp\templates\admin_index.html:6 msgid "SIK Admin" msgstr "SIK Hallintapaneeli" @@ -916,6 +916,14 @@ msgstr "Haku toimariksi olisi hyvä tehdä ennen tätä!" msgid "Vaalikokous, osa 3 (toimarien valinta)" msgstr "Vaalikokous, osa 3 (toimarien valinta)" +#: .\webapp\templates\kaehmy_export.html:9 +msgid "All applications" +msgstr "Kaikki kaehmyt" + +#: .\webapp\templates\kaehmy_export.html:14 +msgid "Front page" +msgstr "Etusivulle" + #: .\webapp\templates\kaehmy_list.html:24 #: .\webapp\templates\kaehmy_list.html:59 msgid "All kaehmys" @@ -1009,13 +1017,4 @@ msgstr "Kaikki haasteet" #: .\webapp\templates\ohlhafv_list.html:15 msgid "Total challenges:" -msgstr "Haasteita yhteensä:" - -#~ msgid "Could not accept application object" -#~ msgstr "Hakemusobjektia ei voitu hyväksyä" - -#~ msgid "Could not update member object" -#~ msgstr "Jäsenobjektia ei voitu päivittää" - -#~ msgid "Summary" -#~ msgstr "Tiivistelmä" +msgstr "Haasteita yhteensä:" \ No newline at end of file diff --git a/webapp/models.py b/webapp/models.py index 9e74274..c6cea6b 100644 --- a/webapp/models.py +++ b/webapp/models.py @@ -226,6 +226,15 @@ class KaehmyForm(MessageParent): combined = presets + customs return _('Official: {}').format(', '.join(combined)) if len(combined) > 0 else '' + def all_roles(self): + presets = [r.name.capitalize() for r in self.preset_roles.all()] + customs = [r.name.capitalize() for r in self.custom_roles.all()] + combined = presets + customs + return ', '.join(combined) if len(combined) > 0 else '' + + def has_any_board_role(self): + return self.preset_roles.filter(is_board=True).exists() or self.custom_roles.filter(is_board=True) + class Role(PresetRole): """ diff --git a/webapp/tables.py b/webapp/tables.py index 186f011..2aff309 100644 --- a/webapp/tables.py +++ b/webapp/tables.py @@ -1,8 +1,20 @@ import django_tables2 as tables from django.utils.translation import ugettext as _ -from webapp.models import OhlhafvChallenge +from webapp.models import OhlhafvChallenge, KaehmyForm class OhlhafvTable(tables.Table): class Meta: model = OhlhafvChallenge + + +class KaehmyExportTable(tables.Table): + class Meta: + model = KaehmyForm + exclude = ['text', 'messageparent_ptr', 'custom_role_name', 'custom_role_is_board'] + + all_roles = tables.Column(verbose_name=_('Roles')) + has_any_board_role = tables.BooleanColumn(verbose_name=_('Applied for board')) + + def __init__(self, *args, **kwargs): + super(KaehmyExportTable, self).__init__(*args, **kwargs) \ No newline at end of file diff --git a/webapp/templates/kaehmy_base.html b/webapp/templates/kaehmy_base.html index 280379c..fc177cb 100644 --- a/webapp/templates/kaehmy_base.html +++ b/webapp/templates/kaehmy_base.html @@ -1,5 +1,12 @@ {% extends "base.html" %} +{% load static %} +{% load i18n %} + +{% block navigation %} + {% include "kaehmy_navigation.html" %} +{% endblock %} + {% block header %}
{% include "kaehmy_header.html" %} diff --git a/webapp/templates/kaehmy_error.html b/webapp/templates/kaehmy_error.html index 25c4b1b..cdcc0ed 100644 --- a/webapp/templates/kaehmy_error.html +++ b/webapp/templates/kaehmy_error.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "kaehmy_base.html" %} {% load static %} {% load i18n %} diff --git a/webapp/templates/kaehmy_export.html b/webapp/templates/kaehmy_export.html new file mode 100644 index 0000000..668ee68 --- /dev/null +++ b/webapp/templates/kaehmy_export.html @@ -0,0 +1,17 @@ +{% extends "kaehmy_base.html" %} + +{% load static %} +{% load i18n %} + +{% block content %} +
+
+

{% trans "All applications" %}

+
+ + {{ table|safe }} + +
+{% endblock content %} diff --git a/webapp/urls.py b/webapp/urls.py index dcbd61b..fb3eb56 100644 --- a/webapp/urls.py +++ b/webapp/urls.py @@ -23,6 +23,7 @@ from webapp.views import kaehmy_list_view from webapp.views import kaehmy_submit from webapp.views import kaehmy_comment from webapp.views import kaehmy_statistics_view +from webapp.views import kaehmy_export_view urlpatterns = [ # main @@ -52,6 +53,7 @@ urlpatterns = [ url(r'^kaehmy/submit', kaehmy_submit), url(r'^kaehmy/add_comment', kaehmy_comment), url(r'^kaehmy/statistics', kaehmy_statistics_view), + url(r'^kaehmy/export', kaehmy_export_view), url(r'^kaehmy', kaehmy_list_view), # ohlhafv diff --git a/webapp/views.py b/webapp/views.py index b273c7e..bf55d84 100644 --- a/webapp/views.py +++ b/webapp/views.py @@ -16,7 +16,8 @@ from dealer.git import git from webapp.models import PresetKaehmyRole, CustomKaehmyRole from webapp.models import OhlhafvChallenge, KaehmyForm, TelegramChannel from webapp.forms import OhlhafvForm, KaehmyForm_Form, KaehmyCommentForm -from webapp.tables import OhlhafvTable +from webapp.tables import OhlhafvTable, KaehmyExportTable +from members.views.utils import * from django.core.mail import send_mail @@ -136,60 +137,6 @@ def contact_view(request, *args, **kwargs): return render(request, "contact.html", {}) -@require_http_methods(["GET"]) -def kaehmy_view(request, *args, **kwargs): - """Render Kaehmy form page.""" - form = KaehmyForm_Form() - return render(request, 'kaehmy.html', {'form': form}) - - -@ensure_csrf_cookie -@require_http_methods(["POST"]) -def kaehmy_submit(request, *args, **kwargs): - """Submit Kaehmy form.""" - form = KaehmyForm_Form(request.POST) - if form.is_valid(): - application = form.save() - custom_name = form.cleaned_data.get('custom_role_name') - custom_is_board = form.cleaned_data.get('custom_role_is_board') - - if len(custom_name) > 0: - custom_role = CustomKaehmyRole( - name=custom_name, is_board=custom_is_board) - custom_role.save() - application.custom_roles.add(custom_role) - - url = 'https://sika.sahkoinsinoorikilta.fi/kaehmy' - - email = form.cleaned_data.get('email', '') - name = form.cleaned_data.get('name', 'Anonymous') - subject = 'Arwokas kirjattu kirje mahdolliselle tulewalle kiltahenkilölle' - body = ('Moikka {}!\r\n\r\nHienoa, että kilta kiinnostaa! Kaehmysi on vastaanotettu.\r\n' - 'Mahdollisista kommenteista tulee ilmoitus sähköpostitse.\r\n\r\n' - 'Käy katsomassa kaehmytilanne osoitteessa {}').format(name, url) - - send_email(email, subject, body) - logging.debug('Sent kaehmy email to recipient <{}>'.format(email)) - - CHAT_IDS = [channel.channel_id for channel in TelegramChannel.objects.all()] - for chat_id in CHAT_IDS: - tg_string = 'https://api.telegram.org/bot{}/sendMessage?chat_id={}&text={}'.format( - settings.TELEGRAM_BOT_TOKEN, - chat_id, - 'Uusi kaehmy/New kaehmy! {} -> {}'.format(name, url) - ) - response = requests.get(tg_string).json() - logging.debug('Telegram API response:\n{}'.format(response)) - logging.debug('Sent kaehmy announcement to {} channels.'.format(len(CHAT_IDS))) - - else: - context = { - 'error': form.errors - } - return render(request, 'kaehmy_error.html', context) - return HttpResponseRedirect('/kaehmy') - - @require_http_methods(["GET"]) def ohlhafv_view(request, *args, **kwargs): """Render Ohlhafv form page.""" @@ -311,3 +258,74 @@ def kaehmy_statistics_view(request, *args, **kwargs): 'role_list': role_list } return render(request, 'kaehmy_statistics.html', context) + + +@require_http_methods(["GET"]) +def kaehmy_view(request, *args, **kwargs): + """Render Kaehmy form page.""" + form = KaehmyForm_Form() + return render(request, 'kaehmy.html', {'form': form}) + + +@ensure_csrf_cookie +@require_http_methods(["POST"]) +def kaehmy_submit(request, *args, **kwargs): + """Submit Kaehmy form.""" + form = KaehmyForm_Form(request.POST) + if form.is_valid(): + application = form.save() + custom_name = form.cleaned_data.get('custom_role_name') + custom_is_board = form.cleaned_data.get('custom_role_is_board') + + if len(custom_name) > 0: + custom_role = CustomKaehmyRole( + name=custom_name, is_board=custom_is_board) + custom_role.save() + application.custom_roles.add(custom_role) + + url = 'https://sika.sahkoinsinoorikilta.fi/kaehmy' + + email = form.cleaned_data.get('email', '') + name = form.cleaned_data.get('name', 'Anonymous') + subject = 'Arwokas kirjattu kirje mahdolliselle tulewalle kiltahenkilölle' + body = ('Moikka {}!\r\n\r\nHienoa, että kilta kiinnostaa! Kaehmysi on vastaanotettu.\r\n' + 'Mahdollisista kommenteista tulee ilmoitus sähköpostitse.\r\n\r\n' + 'Käy katsomassa kaehmytilanne osoitteessa {}').format(name, url) + + send_email(email, subject, body) + logging.debug('Sent kaehmy email to recipient <{}>'.format(email)) + + CHAT_IDS = [channel.channel_id for channel in TelegramChannel.objects.all()] + for chat_id in CHAT_IDS: + tg_string = 'https://api.telegram.org/bot{}/sendMessage?chat_id={}&text={}'.format( + settings.TELEGRAM_BOT_TOKEN, + chat_id, + 'Uusi kaehmy/New kaehmy! {} -> {}'.format(name, url) + ) + response = requests.get(tg_string).json() + logging.debug('Telegram API response:\n{}'.format(response)) + logging.debug('Sent kaehmy announcement to {} channels.'.format(len(CHAT_IDS))) + + else: + context = { + 'error': form.errors + } + return render(request, 'kaehmy_error.html', context) + return HttpResponseRedirect('/kaehmy') + + +@require_http_methods(['GET']) +def kaehmy_export_view(request, *args, **kwargs): + kaehmys = KaehmyForm.objects.all() + + table = KaehmyExportTable(kaehmys, + request=request, + exclude=['id'], + attrs={'class': 'table table-bordered table-hover'}) + + table.paginate(page=request.GET.get('page', 1), per_page=9999) + table_html = convert_table_to_html(table, request) + context = { + 'table': table_html, + } + return render(request, 'kaehmy_export.html', context)