Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/dos'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jani Bonnevier committed May 20, 2020
2 parents 20c51b9 + ad25a41 commit 9d71cd9
Show file tree
Hide file tree
Showing 24 changed files with 554 additions and 526 deletions.
37 changes: 24 additions & 13 deletions libstat/forms/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class SurveyForm(forms.Form):
def _cell_to_input_field(self, cell, observation, authenticated, variable_type):
attrs = {"class": "form-control",
"id": cell.variable_key,
"name": cell.variable_key,
"aria-labelledby": cell.variable_key}
"name": cell.variable_key}

if cell.sum_of:
attrs["data-sum-of"] = " ".join(map(lambda s: s, cell.sum_of))
Expand All @@ -30,6 +29,7 @@ def _cell_to_input_field(self, cell, observation, authenticated, variable_type):
if cell.required == True:
attrs["data-bv-notempty"] = ""
attrs["placeholder"] = "Obligatorisk"
attrs["aria-required"] = "true"

if variable_type in ["integer", "decimal"]:
# Numerical fields need special treatment with JS because of
Expand All @@ -41,6 +41,13 @@ def _cell_to_input_field(self, cell, observation, authenticated, variable_type):
else:
attrs["data-previous-value"] = 'null'

if "Namn" in cell.variable_key:
attrs["autocomplete"] = "name"

if "Plan" in cell.variable_key:
attrs["type"] = "url"
attrs["autocomplete"] = "url"

# Utgifter and Intakter max 999 999 999 or 999 999 999,999
if "Utgift" in cell.variable_key or "Intakt" in cell.variable_key:
attrs["data-bv-regexp"] = ""
Expand Down Expand Up @@ -68,6 +75,8 @@ def _cell_to_input_field(self, cell, observation, authenticated, variable_type):
if variable_type == "email":
#attrs["data-bv-emailaddress"] = ""
attrs["data-bv-regexp"] = ""
attrs["autocomplete"] = "email"
attrs["type"] = "email"
attrs["data-bv-regexp-regexp"] = "^([\w!#$%&'*+/=?`{|}~^-]+(?:\.[\w!#$%&'*+/=?`{|}~^-]+)*@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,6})$"
attrs["data-bv-regexp-message"] = u"Vänligen mata in en giltig emailadress"

Expand All @@ -77,6 +86,8 @@ def _cell_to_input_field(self, cell, observation, authenticated, variable_type):

if variable_type == "phonenumber":
attrs["data-bv-regexp"] = ""
attrs["autocomplete"] = "tel"
attrs["type"] = "tel"
attrs["data-bv-regexp-regexp"] = "^(-|\+?(\d\d?-?)+\d(\s?\d+)*\d+)$"
attrs["data-bv-regexp-message"] = u"Vänligen mata in ett giltigt telefonnummer utan bokstäver och parenteser, t ex 010-709 30 00"

Expand Down Expand Up @@ -136,25 +147,25 @@ def set_library(self, library, current_library=False):
}

if self.is_read_only:
attrs["disabled"] = "true"
attrs["disabled"] = "disabled"

if library.sigel in other_surveys_selected_sigels:
attrs["disabled"] = "true"
attrs["disabled"] = "disabled"
row["comment"] = u"Detta bibliotek rapporteras redan för i en annan enkät."
if current_library or library.sigel in this_surveys_selected_sigels:
row["comment"] = u"Rapporteringen för detta bibliotek kolliderar med en annan enkät."
self.library_selection_conflict = True
del attrs["disabled"]

if current_library:
attrs["disabled"] = "true"
attrs["disabled"] = "disabled"
if not authenticated or library.sigel in this_surveys_selected_sigels:
attrs["checked"] = "true"
attrs["checked"] = "checked"

if not library.sigel in other_surveys_selected_sigels:
row["comment"] = u"Detta är det bibliotek som mottagit denna enkät. Om du samredovisar med andra bibliotek, glöm inte att även kryssa för dem här i listan."
elif library.sigel in this_surveys_selected_sigels:
attrs["checked"] = "true"
attrs["checked"] = "checked"

if authenticated:
try:
Expand Down Expand Up @@ -188,18 +199,18 @@ def _mailto_link(self):
body = (
u"%0D%0A"
u"----------" + "%0D%0A"
u"Var vänlig och låt följande information stå kvar i meddelandet." + "%0D%0A"
u"Var%20vänlig%20och%20låt%20följande%20information%20stå%20kvar%20i%20meddelandet." + "%0D%0A"
u"" + "%0D%0A"
u"Bibliotek: {} ({}) i {}".format(self.library_name, self.library_sigel, self.city) + "%0D%0A"
u"Kommun/län: {} ({})".format(municipalities.get(self.municipality_code, ""), self.municipality_code) + "%0D%0A"
u"Statistikansvarig: {}".format(self.email) + "%0D%0A"
u"Insamlingsår: {}".format(self.sample_year) + "%0D%0A"
u"Bibliotek:%20{}%20({})%20i%20{}".format(self.library_name, self.library_sigel, self.city) + "%0D%0A"
u"Kommun/län:%20{}%20({})".format(municipalities.get(self.municipality_code, ""), self.municipality_code) + "%0D%0A"
u"Statistikansvarig:%20{}".format(self.email) + "%0D%0A"
u"Insamlingsår:%20{}".format(self.sample_year) + "%0D%0A"
u"----------"
)

return (
u"mailto:[email protected]"
u"?subject=Fråga för statistikenkät: {} ({})".format(self.library_name, self.library_sigel) +
u"?subject=Fråga%20för%20statistikenkät:%20{}%20({})".format(self.library_name, self.library_sigel) +
u"&body={}".format(body)
)

Expand Down
2 changes: 1 addition & 1 deletion libstat/templates/libstat/administration.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% if message %}
<div class="row">
<div class="col-md-6">
<div class="alert alert-info" role="alert">
<div class="alert alert-info" role="alert" aria-atomic="true">
{{ message|linebreaks }}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion libstat/templates/libstat/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

<div class="row row-inside row-alert hidden" style="margin-top: 15px;">
<div class="col-xs-12 col-inside">
<div class="alert alert-danger alert-reports" role="alert" style="margin-bottom: 0;">
<div class="alert alert-danger alert-reports" role="alert" aria-atomic="true" style="margin-bottom: 0;">
<p><i class='fa fa-warning fa-fw'></i> Du måste ange både en rubrik och innehåll för inlägget.</p>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions libstat/templates/libstat/base/admin/login.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="login-modal-title" aria-hidden="true">
<form role="form" class="login-form" method="post" action="">
<form class="login-form" method="post" action="#">
{% csrf_token %}

<div class="modal-dialog">
Expand All @@ -19,7 +19,7 @@ <h4 class="modal-title" id="login-modal-title">Logga in i Biblioteksstatistiken<
<div class="form-group">
<label for="username">Användarnamn</label>
<input id="username" name="username" type="text" value="{{ form.instance.username }}"
class="form-control"/>
class="form-control"/>
<span class="text-danger errors username"></span>
</div>
<div class="form-group">
Expand Down
1 change: 0 additions & 1 deletion libstat/templates/libstat/base/admin_survey.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Biblioteksstatistiken</title>
Expand Down
52 changes: 16 additions & 36 deletions libstat/templates/libstat/base/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Kungl. bibliotekets statistik om Sveriges offentligt finansierade bibliotek">

Expand All @@ -26,45 +25,26 @@
{% endblock %}

<footer>
<hr>
<p style="padding:10px;text-align:center;">
Kungliga biblioteket hanterar dina personuppgifter i enlighet med EU:s dataskyddsförordning (2018), GDPR. <a href="https://www.kb.se/omoss/dataskydd.html">Läs mer om hur det funkar här</a>.
<br>
Så här hanterar KB dina uppgifter vid <a href="https://www.kb.se/omoss/dataskydd.html#Bibstat">användning av denna tjänst.</a>
</p>
<div class="container text-center">
<p>{% footer %}<br>{% block footer %}{% endblock %}</p>
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-2 logo-container">
<img src="/static/img/kb.svg" class="intro-logo" alt="Kungliga biblioteket">
</div>
<div class="col-xs-12 col-sm-10">
<nav aria-label="Länkar i sidfot">
<ul class="footer-list">
<li><a href="https://www.kb.se/omoss/dataskydd.html#Bibstat">Om dataskydd (GDPR)</a></li>
<li><a href="https://www.kb.se/digital-tillganglighet">Tillgänglighetsredogörelse</a></li>
<li><a href="https://github.com/libris/bibstat/releases">Versionsinformation</a></li>
</ul>
</nav>
<span class="footer-notes">{% footer %}<br>{% block footer %}{% endblock %}</span>
</div>
</div>
</div>
</footer>

<script src="/static/js/plugins/requirejs/require.js"></script>
<script src="/static/js/main.js"></script>

<!-- Kundo forum
<script type="text/javascript">
var _kundo = _kundo || {};
_kundo["org"] = "biblioteksstatistiken";
_kundo["lang"] = "sv";
_kundo["btn-type"] = "4";
_kundo["top"] = "50%";
(function() {
function async_load(){
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = ('https:' == document.location.protocol ? 'https://static-ssl' : 'http://static') +
'.kundo.se/embed.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent)
window.attachEvent('onload', async_load);
else
window.addEventListener('load', async_load, false);
})();
</script>
-->
</body>
</html>
10 changes: 5 additions & 5 deletions libstat/templates/libstat/dispatches.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{% if message %}
<div class="row">
<div class="col-md-6">
<div class="alert alert-info" role="alert">
<div class="alert alert-info" aria-atomic="true" role="alert">
{{ message|linebreaks }}
</div>
</div>
Expand All @@ -40,7 +40,7 @@
</div>
</div>
<hr>
<form action="" method="post" class="form-inline form-dispatches">
<form action="#" method="post" class="form-inline form-dispatches">
{% csrf_token %}

<table class="table table-dispatches table-striped">
Expand All @@ -65,9 +65,9 @@
<td>{{ dispatch.library_city|default:"" }}</td>
<td>{{ dispatch.library_email|default:"" }}</td>
<td><a class="show-dispatch survey-popover" href="#" data-title="{{ dispatch.title }}"
data-message="{{ dispatch.message|linebreaks }}"
data-placement="top" data-toggle="tooltip"
data-original-title="Visa e-postmeddelandet">Förhandsgranska</a></td>
data-message="{{ dispatch.message|linebreaks }}"
data-placement="top" data-toggle="tooltip"
data-original-title="Visa e-postmeddelandet">Förhandsgranska</a></td>
</tr>
{% endfor %}
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion libstat/templates/libstat/email_template.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img src="http://bibstat.kb.se/static/img/kb-logo.png">
<img src="http://bibstat.kb.se/static/img/kb-logo.png" alt="Kungliga biblioteket">
<br>
{{ message|linebreaksbr }}
<br>
Expand Down
Loading

0 comments on commit 9d71cd9

Please sign in to comment.