Commit 60ef9a63 authored by Gino's avatar Gino

Imports updated

parent f9d88fe7
......@@ -37,6 +37,7 @@ class ElectedImporter:
def populate(self, limit=0):
elected_in_db = 0
with open(self.json_file) as f:
data = json.load(f)
for elected in data["elected"]:
......@@ -68,6 +69,7 @@ class ElectedImporter:
else:
new_elected.photo = settings.SITE_URL + "static/img/avatar_h.png"
new_elected.save()
# print('added')
elected_in_db += 1
if elected_in_db == limit:
break
......
......@@ -135,12 +135,12 @@ def actiongroup_generate_slug(sender, instance, **kwargs):
for index in itertools.count(1):
if not ActionGroup.objects.filter(slug=instance.slug).exists():
break
instance.slug = f"{default_slug}-{index}"
instance.slug = "{}-{}".format(default_slug, index)
@receiver(pre_save, sender=Representative)
def representative_generate_slug(sender, instance, **kwargs):
instance.slug = default_slug = slugify(f"{instance.firstname} {instance.lastname}")
instance.slug = default_slug = slugify("{} {}".format(instance.firstname, instance.lastname))
for index in itertools.count(1):
if not Representative.objects.filter(slug=instance.slug).exists():
break
instance.slug = f"{default_slug}-{index}"
\ No newline at end of file
instance.slug = "{}-{}".format(default_slug, index)
\ No newline at end of file
......@@ -19,7 +19,13 @@
<div id="action-group-wrapper">
<div class="actiongroup-info">
<sib-ac-checker
bind-resources
permission="acl:Write">Salut</sib-ac-checker>
<sib-ac-checker
bind-resources
permission="acl:TOTO">NIET</sib-ac-checker>
<div class="section-head">
<div style="display: flex; align-items: center;">
<sib-display
......@@ -109,12 +115,6 @@ perm par défaut "read" {% endcomment %}
</div>
<div id="action-group-representatives">
<strong>Élus concernés</strong>
{% comment %} <sib-display
bind-resources
id-suffix="representatives"
data-fields="firstname, lastname"
next="representative-detail"
></sib-display> {% endcomment %}
<sib-display
bind-resources
......@@ -124,14 +124,6 @@ perm par défaut "read" {% endcomment %}
next="representative-detail"
></sib-display>
{% comment %} <sib-display
bind-resources
data-fields="representatives"
widget-representatives="u4e-display-rep-fullname"
next="representative-detail"
></sib-display> {% endcomment %}
<strong>Groupes associés</strong>
<sib-display
bind-resources
......
......@@ -84,6 +84,7 @@
widget-actiongroups="sib-form-auto-completion"
range-actiongroups="{{ domain }}/api/action-groups/"
next="groupes-action-list"
{% comment %} next="action-group-detail" {% endcomment %}
></sib-form>
</div>
{% endif %}
......
......@@ -18,6 +18,7 @@
>► Voir tous les&nbsp;groupes
</sib-link>
<sib-display
id="testpop"
data-src="{{ domain }}/api/action-groups/"
value-voir="voir"
data-fields="name, image, voir"
......
......@@ -15,9 +15,14 @@ APP STRUCTURE:
<head>
<meta charset="utf-8">
<title>United4Earth</title>
<script type="module" src="https://cdn.happy-dev.fr/sib-router/sib-router.js"></script>
{% comment %} <script type="module" src="https://cdn.happy-dev.fr/sib-router/sib-router.js"></script>
<script type="module" src="https://cdn.happy-dev.fr/sib-core/sib-display.js"></script>
<script type="module" src="https://cdn.happy-dev.fr/sib-core/sib-form.js"></script>
<script type="module" src="https://cdn.happy-dev.fr/sib-core/sib-form.js"></script> {% endcomment %}
<script type="module" src="https://unpkg.com/@startinblox/core@latest"></script>
<script type="module" src="https://unpkg.com/@startinblox/router@latest"></script>
{% comment %} <script type="module" src="https://unpkg.com/@startinblox/component-conversation"></script> {% endcomment %}
{% comment %} <script type="module" src="https://cdn.happy-dev.fr/sib-conversation/sib-conversation.js"></script> {% endcomment %}
{% comment %} <script type="module" src="https://unpkg.com/@startinblox/core@latest"></script>
......@@ -197,14 +202,25 @@ actiongroup_edit_button.addEventListener("click", function (e) {
});*/
/*
*/
var add_representative_form = document.getElementById("sib-form-add-representative");
add_representative_form.addEventListener('populate', function(event) {
console.log("representatives-add populated");
const button = document.querySelector('#representatives-add form input[type="submit"]');
let extra_button = document.createElement('button');
extra_button.textContent = "suivant";
document.querySelector('#representatives-add form').appendChild(extra_button);
//button.setAttribute('value', "suivant");
button.setAttribute('disabled');
});
</script>
{% comment %} <script src="https://code.j.com/j-3.3.1.slim.min.js" integrity="sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> {% endcomment %}
<script src="{% static 'js/main.js' %}"></script>
<script src="{% static 'js/main.js' %}"></script>
<script src="{% static 'js/moment-with-locales.min.js' %}"></script>
<script type="module" src="{% static 'js/widgets.js' %}"></script>
{% comment %} <script type="module" src="{% static 'js/widgets-representatives.js' %}"></script> {% endcomment %}
......
......@@ -48,6 +48,18 @@
{% comment %} value-firstname="test" {% endcomment %}
next="representative-detail"
{% comment %} search-widget-firstname="sib-form-placeholder-text" {% endcomment %}
search-label-firstname='Prénom',
search-widget-firstname='sib-form-placeholder-text'
search-label-lastname='Nom'
search-widget-lastname='sib-form-placeholder-text'
search-label-function='Fonction'
search-widget-function='sib-form-placeholder-text'
search-label-election_region='Région'
search-widget-election_region='sib-form-placeholder-text'
search-label-political_party='Parti politique'
search-widget-political_party='sib-form-placeholder-text'
paginate-by="20"
>
</sib-display>
......@@ -59,16 +71,44 @@
<sib-form
id="sib-form-add-representative"
data-src="{{ domain }}/api/representatives/"
data-fields="civil, political, contact"
{% comment %} set-civil="title-civil, firstname, lastname, function, title, protocol_role, protocol_person, photo" {% endcomment %}
set-civil="title-civil, lastname, firstname, civility, political_part, function, election_department, city, postal_code, country"
value-title-civil="Informations principales"
widget-title-civil="sib-display-div"
label-lastname="Nom"
label-firstname="Prénom"
label-civility="Civilité"
label-political_part="Parti politique"
label-function="Fonction"
label-election_department="Département d'élection"
label-city="Ville"
label-postal_code="Code postal"
label-country="Pays"
set-contact="title-contact, phone_direct, phone_organization, email_direct, email_organization, address1, city, website"
value-title-contact="Informations de contact"
widget-title-contact="sib-display-div"
label-phone_direct="Tél. direct"
label-phone_organization="Tél. organisation"
label-email_direct="Email direct"
label-email_organization="Email organisation"
label-address1="Adresse"
label-website="Site web"
{% comment %}
set-civil="title-civil, firstname, lastname, civility, title, function, title, protocol_role, protocol_person, photo"
set-civil="firstname, lastname, function, title, protocol_role, protocol_person, photo"
{% comment %} value-title-civil="salut" {% endcomment %}
{% comment %} value-title-civil="Civilité & protocole" {% endcomment %}
{% comment %} widget-title-civil="sib-display-form-title" {% endcomment %}
{% comment %} value-next-button="suivant" {% endcomment %}
{% comment %} widget-next-button="sib-display-button" {% endcomment %}
set-political="political_party, election_department, election_region, organization_type, organization_subtype"
set-contact="phone_direct, phone_organization, email_direct, email_organization, address1, address2, postal_code, city, country, website"
value-title-civil="salut"
value-title-civil="Civilité & protocole"
widget-title-civil="sib-display-form-title"
value-next-button="suivant"
widget-next-button="sib-display-button"
set-political="election_region, organization_type, organization_subtype"
label-firstname="Prénom*"
label-lastname="Nom*"
label-function="Fonction"
......@@ -91,6 +131,8 @@
label-organization_type="Type d'organisation"
label-organization_subtype="Sous-type d'organisation"
label-photo="Photo (URL)"
{% endcomment %}
next="representatives-list"
></sib-form>
</div>
......
......@@ -56,7 +56,7 @@ urlpatterns = [
model=Representative,
# permission_classes=(AnonymousReadOnly,),
permission_classes=(),
# lookup_field='slug',
lookup_field='slug',
), name='representatives_sib'),
# This URL have to be in last position:
......
File mode changed from 100644 to 100755
backcall==0.1.0
certifi==2018.10.15
certifi==2018.11.29
chardet==3.0.4
colorama==0.4.1
decorator==4.3.0
Django==1.11.17
Django==1.11
django-guardian==1.4.9
django-registration-redux==2.5
django-rest-framework==0.1.0
djangoldp==0.5a12
djangorestframework==3.9.0
djangorestframework-guardian==0.1.1
idna==2.7
ipython==7.2.0
ipython-genutils==0.2.0
jedi==0.13.1
parso==0.3.1
pickleshare==0.7.5
prompt-toolkit==2.0.7
psycopg2==2.7.6.1
Pygments==2.3.0
djangoldp==0.5.16
djangoldp-conversation==0.0.4
djangorestframework==3.9.1
idna==2.8
psycopg2==2.7.7
PyLD==1.0.4
pytz==2018.7
requests==2.20.1
pytz==2018.9
requests==2.21.0
six==1.12.0
traitlets==4.3.2
urllib3==1.24.1
wcwidth==0.1.7
xlrd==1.1.0
......@@ -71,14 +71,14 @@ h1, h2, #baseline {
===================
*/
#call-mobile-menu {
width: 5%;
width: 3%;
position: fixed;
top: 2vmax;
z-index: 10;
display: none;
}
#call-mobile-menu {
left: 2vmax;
left: 5vw;
}
/*
=================
......@@ -471,7 +471,7 @@ aside sib-display[id-suffix="actiongroups"] > div sib-display{
margin-right: 7px;
padding: 5px 0;
}
#sib-representatives-list > sib-form form sib-form-label-text {
/* #sib-representatives-list > sib-form form sib-form-label-text {
padding: 0;
border-bottom: none;
}
......@@ -498,7 +498,7 @@ aside sib-display[id-suffix="actiongroups"] > div sib-display{
#sib-representatives-list > sib-form form sib-form-label-text input:focus {
border: 1px solid #24c70b;
box-shadow: 0px 2px 2px rgba(0,0,0,0.1);
}
} */
#sib-representatives-list > sib-form form input[type="submit"],
#sib-representatives-list > sib-form form input[type="reset"] {
margin: 5px 10px;
......@@ -518,7 +518,7 @@ aside sib-display[id-suffix="actiongroups"] > div sib-display{
#sib-representatives-list > sib-form form input[type="submit"] {
display: none;;
}
#sib-representatives-list sib-form-label-text[name="firstname"],
/* #sib-representatives-list sib-form-label-text[name="firstname"],
#sib-representatives-list sib-form-label-text[name="lastname"],
#sib-representatives-list sib-form-label-text[name="function"] {
flex-basis: 10%;
......@@ -529,7 +529,8 @@ aside sib-display[id-suffix="actiongroups"] > div sib-display{
}
#sib-representatives-list > sib-form form sib-form-label-text label {
display: none;
}
} */
/*
=============================
REPRESENTATIVE DETAIL
......@@ -581,6 +582,14 @@ aside sib-display[id-suffix="actiongroups"] > div sib-display{
.profile h1 {
text-align: center;
}
/*#representatives-add div[name="title-civil"],
#representatives-add div[name="title-contact"] {
font-weight: bold;
text-align: center;
}
#representatives-add div[name="contact"] {
display: none;
} */
.sib-form form {
display: flex;
......@@ -858,15 +867,6 @@ footer {
RESPONSIVE
==================
*/
@media only screen and (max-width: 1024px) {
.representatives-list div sib-display div[name="fullname"] {
height: 3em;
}
#home .representatives-list div sib-display:nth-child(n+5) {
display: none;
}
}
@media only screen and (max-width: 1366px) {
.representatives-list div sib-display div[name="fullname"] {
......@@ -899,6 +899,82 @@ footer {
display: none;
}
}
@media only screen and (max-width: 1024px) {
.representatives-list div sib-display div[name="fullname"] {
height: 3em;
}
#home .representatives-list div sib-display:nth-child(n+5) {
display: none;
}
}
@media only screen and (max-width: 768px) {
body {
padding: 1vh 5vw;
margin: 0;
width: 90vw;
}
#logo {
margin: 1em;
width: 15%;
}
#header a {
width: 100%;
flex-basis: unset;
text-align: center;
}
#call-mobile-menu {
display: block;
}
#account-menu ul li {
font-weight: bold;
}
#main-menu {
position: fixed;
top: 0;
margin: 0;
border-top: none;
padding-top: 7vh;
width: 100vw;
height: 50vh;
transition: all 0.25s;
z-index: 5;
background: #FFF;
box-shadow: -5px 7px 5px rgba(0,0,0,0.1);
background: rgba(255, 255, 255, 0.9);
left: -100vw;
}
#account-menu {
text-align: left;
}
#account-menu ul {
transform: translateX(-10vw);
padding-left: 0 !important;
}
#main-menu ul {
flex-direction: column;
}
#main-menu ul li {
margin-top: 3vh;
text-align: left;
display: block;
}
#home-icon {
display: none;
}
#home-text {
display: inline;
}
.separator {
display: none;
}
.menu-on-l {
transform: translateX(100vw);
}
.see-all {
transform: translateY(5em);
}
}
@media only screen and (max-width: 480px) {
body {
padding: 0;
......@@ -936,6 +1012,7 @@ footer {
}
#call-mobile-menu {
display: block;
width: 5%;
}
#account-menu ul li {
font-weight: bold;
......@@ -984,8 +1061,6 @@ footer {
}
.section-head {
display: block;
/* flex-wrap: wrap; */
/* flex-direction: column; */
}
button {
margin: 2em;
......
import { SIBWidget, SIBMultipleWidget } from "https://cdn.happy-dev.fr/sib-core/widgets/sib-base-widgets.js";
//import { SIBWidget, SIBMultipleWidget, SIBFormMultipleValue, SIBFormAutoCompletion, importCSS, uniqID, store } from "https://unpkg.com/@startinblox/core@latest";
import { SIBWidget, SIBMultipleWidget, SIBFormMultipleValue, SIBFormAutoCompletion, Helpers, store } from "https://unpkg.com/@startinblox/core@latest";
//const {importCSS} = Helpers;
/*import { SIBWidget, SIBMultipleWidget } from "https://cdn.happy-dev.fr/sib-core/widgets/sib-base-widgets.js";
import { SIBFormMultipleValue, SIBFormAutoCompletion } from "https://cdn.happy-dev.fr/sib-core/widgets/sib-form-widgets.js";
import { importCSS, uniqID } from "https://cdn.happy-dev.fr/sib-core/helpers.js";
import { store } from "https://cdn.happy-dev.fr/sib-core/store.js";
import { store } from "https://cdn.happy-dev.fr/sib-core/store.js";*/
import Choices from 'https://dev.jspm.io/choices.js@4';
//import { SIBWidget, SIBMultipleWidget, SIBFormMultipleValue, SIBFormAutoCompletion, uniqID, store } from 'https://unpkg.com/@startinblox/core@latest';
......@@ -114,7 +119,7 @@ class U4EFormAutoCompletionRep extends SIBFormAutoCompletion {
options.forEach(option => select.appendChild(option));
this.parent.appendChild(select);
new Choices(select, { removeItemButton: true });
importCSS('https://dev.jspm.io/npm:choices.js@4/public/assets/styles/choices.min.css')
Helpers.importCSS('https://dev.jspm.io/npm:choices.js@4/public/assets/styles/choices.min.css')
}
// set range(url) {
// store.list(url).then(list => {
......@@ -158,7 +163,7 @@ class U4EFormAutoCompletionRep extends SIBFormAutoCompletion {
options.forEach(option => select.appendChild(option));
this.parent.appendChild(select);
new Choices(select, { removeItemButton: true });
importCSS('https://dev.jspm.io/npm:choices.js@4/public/assets/styles/choices.min.css')
Helpers.importCSS('https://dev.jspm.io/npm:choices.js@4/public/assets/styles/choices.min.css')
}
}
customElements.define('u4e-form-auto-completion-rep2', U4EFormAutoCompletionRep2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment