Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezekiah committed Jul 1, 2013
1 parent 3e77dfd commit 642ddea
Show file tree
Hide file tree
Showing 28 changed files with 285 additions and 101 deletions.
3 changes: 2 additions & 1 deletion glue/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ def meta( self, key, value, jsonify=False):
return value


def throw_error( self, error="", code=API_EXCEPTION ):
def throw_error( self, error="", code=API_EXCEPTION, fields="" ):
self.response[ 'status' ] = 'error'
self.response[ 'error' ] = error
self.response[ 'code' ] = code
self.response[ 'fields' ] = fields

return self

Binary file modified locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
17 changes: 16 additions & 1 deletion locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ msgstr ""
msgid "selected page does not exists"
msgstr ""


msgid "This email is already used in the database."
msgstr "Cet email est déjà utilisé sur le site"


#: glue/api.py:83 outside/api.py:121
#, python-format
msgid "selected pin does not exists. Exception: %s"
Expand Down Expand Up @@ -79,6 +84,13 @@ msgstr "beQuali demande d'accès pour enquête"
msgid "This username is already used"
msgstr "Cet identifiant est déjà utilisé"


#: outside/api.py
msgid "This email does not exists"
msgstr "Cet email n'existe pas"



#: outside/api.py:520
msgid "beQuali signup"
msgstr "beQuali inscription"
Expand Down Expand Up @@ -809,6 +821,9 @@ msgstr "Ajouter"
msgid "cancel"
msgstr "Annuler"

msgid "signup"
msgstr "inscription"

#: outside/templates/enquete/enquetes.html:34
msgid "enquetes"
msgstr ""
Expand Down Expand Up @@ -1301,7 +1316,7 @@ msgstr ""
#: outside/templates/hub/signup.html:31
msgid "You will login to the site with this username"
msgstr ""
"Vous vous connecterez sur le site avec cet identifiant, les accents et "
"Vous vous connecterez sur le site avec cet identifiant, les accents, majuscules et "
"caractères spéciaux sont interdits"

#: outside/templates/hub/signup.html:54
Expand Down
87 changes: 72 additions & 15 deletions outside/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
from django.db.models import Q
from django.conf import settings
from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.core.mail import send_mail, EmailMultiAlternatives
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response, redirect, get_object_or_404
from django.http import HttpResponse, HttpRequest, HttpResponseRedirect

from django.template import RequestContext
from django.template.defaultfilters import slugify

from django.core.mail import EmailMultiAlternatives


from glue.models import Pin
Expand Down Expand Up @@ -330,7 +329,7 @@ def contacts( request ):
#Notification mail to the client
subject, from_email, to = _('beQuali : Message sent'),_("beQuali Team")+"<equipe@bequali.fr>", form.cleaned_data['email']

html_content = render_to_string('email/contact.html', email_args, RequestContext(request, i18n()))
html_content = render_to_string('email/contact.html', email_args, RequestContext(request, {'REANALYSEURL': settings.REANALYSEURL+'/'+settings.OUTSIDE_SITE_NAME}))
text_content = strip_tags(html_content) # this strips the html, so people will have the text as well.

# create the email, and attach the HTML version as well.
Expand All @@ -342,7 +341,7 @@ def contacts( request ):
#Send mail to bequali admin : sarah.cadorel@sciences-po.fr, guillaume.garcia, anne.both
subject, from_email, to = _('beQuali contact request'),'admin@bequali.fr', settings.EMAIL_ADMINS

html_content = render_to_string('email/contact.html', email_args, RequestContext(request, i18n()))
html_content = render_to_string('email/contact.html', email_args, RequestContext(request, {'REANALYSEURL': settings.REANALYSEURL+'/'+settings.OUTSIDE_SITE_NAME}))
text_content = strip_tags(html_content) # this strips the html, so people will have the text as well.

# create the email, and attach the HTML version as well.
Expand Down Expand Up @@ -407,9 +406,8 @@ def access_request( request ):
'site': settings.OUTSIDE_SITE_NAME,
'description': form.cleaned_data['description'],
'enquete': form.cleaned_data['enquete'],
'url': path}, RequestContext(request, i18n())
'url': path}, RequestContext(request, {'REANALYSEURL': settings.REANALYSEURL+'/'+settings.OUTSIDE_SITE_NAME}))

)
text_content = strip_tags(html_content) # this strips the html, so people will have the text as well.

# create the email, and attach the HTML version as well.
Expand Down Expand Up @@ -453,8 +451,26 @@ def signups(request):
error={'password1':'Please enter and confirm your password',
'password2':'Please enter and confirm your password'},
code=API_EXCEPTION_FORMERRORS).json()
"""else:
if CheckPassword( form.cleaned_data['password1'] ) < 3 :
return response.throw_error(
error=_('The password stength is too weak.'),
code=API_EXCEPTION_FORMERRORS,
fields={'password1':'', 'password2':''}
).json()
"""

#Check email already exists in database



if User.objects.filter( email = form.cleaned_data['email'] ).count() > 0 :
return response.throw_error(
error=_('This email is already used in the database.'),
code=API_EXCEPTION_FORMERRORS,
fields={'email':''}).json()


try:
created_user = User.objects.get( username = form.cleaned_data['username'] )
Expand All @@ -464,18 +480,18 @@ def signups(request):
created_user = User.objects.create(
first_name = form.cleaned_data['first_name'],
last_name = form.cleaned_data['last_name'],
username = form.cleaned_data['username'],
username = form.cleaned_data['username'].lower(),
email = form.cleaned_data['email'],
is_active = False,
)

created_user.set_password(str(form.cleaned_data['password2']))
created_user.save()


else: #If the user already exists

return response.throw_error( error=_('This username is already used'), code=API_EXCEPTION_INTEGRITY).json()
return response.throw_error( error=_('This username is already used'), code=API_EXCEPTION_INTEGRITY, fields={"username":""}).json()



Expand All @@ -497,15 +513,48 @@ def signups(request):
)
s.save()

send_confirmation_mail( subscriber=s, request=request, action="signup" )
mail_send = send_confirmation_mail( subscriber=s, request=request, action="signup" )


if( mail_send == False ):
created_user.delete()
return response.throw_error( error=_('This email does not exists'), code=API_EXCEPTION_INTEGRITY, fields={"email":""}).json()

return response.queryset( Subscriber.objects.filter() ).json()



def send_confirmation_mail( subscriber, request, action ):


import re
def CheckPassword(password):
strength = ['Blank','Very Weak','Weak','Medium','Strong','Very Strong']
score = 1

if len(password) < 1:
return strength[0]
if len(password) < 4:
return strength[1]

if len(password) >=8:
score = score + 1
if len(password) >=10:
score = score + 1

if re.search('\d+',password):
score = score + 1
if re.search('[a-z]',password) and re.search('[A-Z]',password):
score = score + 1
if re.search('.[!,@,#,$,%,^,&,*,?,_,~,-,£,(,)]',password):
score = score + 1

return score



import smtplib

def send_confirmation_mail( subscriber, request, action ):

if(action == 'signup'):

confirmation_code = ''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for x in range(33))
Expand Down Expand Up @@ -538,13 +587,21 @@ def send_confirmation_mail( subscriber, request, action ):
'password': '**********',#request.REQUEST['password1'],


}, RequestContext(request, i18n()))
}, RequestContext(request, {'REANALYSEURL': settings.REANALYSEURL+'/'+settings.OUTSIDE_SITE_NAME}))

text_content = strip_tags(html_content) # this strips the html, so people will have the text as well.

msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send()

try:

msg.send()

except Exception, e:
return False
else :
return True

elif( action == 'reinitialize_password'):

Expand Down Expand Up @@ -580,7 +637,7 @@ def send_confirmation_mail( subscriber, request, action ):
'confirmation_href': confirmation_href,
'username': subscriber.user.username,

}, RequestContext(request, i18n()))
}, RequestContext(request, {'REANALYSEURL': settings.REANALYSEURL+'/'+settings.OUTSIDE_SITE_NAME}))



Expand Down
4 changes: 2 additions & 2 deletions outside/templates/email/access_request.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Vous pouvez cliquer <a href="{{url}}">ici</a> pour accéder à la page admin<br/>

Aurevoir<br/>
<img src="{{ STATIC_URL }}/img/bequali-logo.png"/>
<img src="{{REANALYSEURL}}/static/img/bequali-logo.png"/>

{% endblocktrans %}

Expand All @@ -36,7 +36,7 @@
Votre demande d'accès pour l'enquête "{{enquete}}" a été acceptée. Vous pouvez consulter l'enquête <a href="{{url}}">ici</a><br/><br/>

Aurevoir
<img src="{{ STATIC_URL }}/img/bequali-logo.png"/>
<img src="{{REANALYSEURL}}/static/img/bequali-logo.png"/>

{% endblocktrans %}

Expand Down
4 changes: 2 additions & 2 deletions outside/templates/email/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

Aurevoir<br/>

<img src="{{ STATIC_URL }}/img/bequali-logo.png"/>
<img src="{{REANALYSEURL}}/static/img/bequali-logo.png"/>

{% endblocktrans %}

Expand All @@ -38,7 +38,7 @@
<br/><br/>

Aurevoir<br/>
<img src="{{ STATIC_URL }}/static/img/bequali-logo.png"/>
<img src="{{REANALYSEURL}}/static/img/bequali-logo.png"/>

{% endblocktrans %}

Expand Down
4 changes: 2 additions & 2 deletions outside/templates/email/reinitialize_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

A bientôt<br/>

<img src="{{ STATIC_URL }}/img/bequali-logo.png"/>
<img src="{{REANALYSEURL}}/static/img/bequali-logo.png"/>

{%endif%}

Expand All @@ -31,7 +31,7 @@

A bientôt<br/>

<img src="{{ STATIC_URL }}/img/bequali-logo.png"/>
<img src="{{REANALYSEURL}}/static/img/bequali-logo.png"/>

{%endif%}

5 changes: 3 additions & 2 deletions outside/templates/email/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

Aurevoir<br/>

<img src="{{ STATIC_URL }}/img/bequali-logo.png"/>
<img src="{{REANALYSEURL}}/static/img/bequali-logo.png"/>

{% endblocktrans %}

Expand All @@ -37,7 +37,8 @@
Vous pouvez cliquer <a href="{{admin_url}}">ici</a> pour accéder à la page admin<br/>

Aurevoir<br/>
<img src="{{ STATIC_URL }}/static/img/bequali-logo.png"/>

<img src="{{REANALYSEURL}}/static/img/bequali-logo.png"/>

{% endblocktrans %}

Expand Down
15 changes: 12 additions & 3 deletions outside/templates/enquete/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ <h3>{{ enquete.name }}</h3>
<div id="tei-settings">

<div id="counter">
<span class="docLabel"><i style="font-size:22px" class="icon-pencil"></i> {% trans "Settings"%}</span>
<span class="docLabel"><i style="font-size:22px" class="icon-wrench"></i> {% trans "Settings"%}</span>
</div>

<div class="leftmenublock">
Expand Down Expand Up @@ -699,16 +699,21 @@ <h3 style="font-size:23px;margin:0px">{{ document.name }} </h3>

// TOGGLE Speakers
{% for s in texte.speaker_set.all %}

$(this).css({'cursor':'wait'})
$('#spkCheck_{{s.id}}').click(function() {

console.log("toggle spk:{{s.id}}");

//$(this).css({'cursor':'wait'})
$("#tei-settings input").attr("disabled", true);
$('.ajax-loader-div0').show ('slow', function(){
$('.speaker_{{s.id}}').toggle();
$('.ajax-loader-div0').hide();
$(this).css({'cursor':'default'})

$("#tei-settings input").removeAttr("disabled");
});

});
{% endfor %}

Expand Down Expand Up @@ -737,6 +742,8 @@ <h3 style="font-size:23px;margin:0px">{{ document.name }} </h3>
{% endfor %}
{% endfor %}

$(this).css({'cursor':'default'})

$('.ajax-loader-div').hide();

$("#tei-settings input").removeAttr("disabled");
Expand All @@ -749,7 +756,7 @@ <h3 style="font-size:23px;margin:0px">{{ document.name }} </h3>
{% for k,parvs in paraverbal.items %}
{% for p,o,c in parvs %}
$('#paraCheck_{{p}}').click(function() {

$(this).css({'cursor':'wait'})
$("#tei-settings input").attr("disabled", true);
$('.ajax-loader-div').show ('slow', function(){

Expand All @@ -761,6 +768,8 @@ <h3 style="font-size:23px;margin:0px">{{ document.name }} </h3>

$('.ajax-loader-div').hide();
$("#tei-settings input").removeAttr("disabled");
$(this).css({'cursor':'default'})

});
});
{% endfor %}
Expand Down
5 changes: 4 additions & 1 deletion outside/templates/enquete/enquete.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ <h3>{{ enquete.name }}</h3>
<!-- Button to trigger modal -->
&nbsp;&nbsp;&nbsp;

<a id="help-general" href="#modal-help-general" role="button" class="btn_help_modal help-icon" data-toggle="modal">




<a id="help-general" href="#modal-help-general" role="button" class="btn_help_modal help-icon" data-toggle="modal">
<em><b> Comment utiliser les outils d'exporation?</b></em>

</a>
Expand Down
2 changes: 1 addition & 1 deletion outside/templates/enquete/metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% block less%}
{{ block.super }}
<link rel="stylesheet/less" type="text/css" href="{{ STATIC_URL }}css/enquete.less">
<!--<link rel="stylesheet/less" type="text/css" href="{{ STATIC_URL }}css/enquete.less">-->

{% endblock %}

Expand Down
Loading

0 comments on commit 642ddea

Please sign in to comment.