Commit a45d8db1 authored by Administrator's avatar Administrator

Merge branch 'testing'

Login/logout and parser
parents 0073a5ea 0f39af9a
......@@ -18,6 +18,7 @@ urlpatterns = patterns('',
url(r'^grappelli/', include('grappelli.urls')),
url(r'^auth/$', views.login_user),
url(r'^auth/logout/$', views.logout_user),
# User Home view
url(r'^$', views.home),
......
......@@ -51,6 +51,10 @@ def login_user(request):
return render_to_response('authentication.html', context_instance=RequestContext(request))
def logout_user(request):
logout(request)
return HttpResponseRedirect('/')
# Redirect to a success page.
def query_to_dicts(query_string, *query_args):
"""Run a simple query and produce a generator
......@@ -117,7 +121,7 @@ def projects(request):
To each project, we can link a resource that can be an image.
'''
if not request.user.is_authenticated():
return redirect('/admin/logout/?next=%s' % request.path)
return redirect('/auth/')
t = get_template('projects.html')
......
......@@ -3,6 +3,7 @@ import locale
from lxml import etree
from datetime import datetime, date
from django.utils import timezone
import dateutil.parser
from .FileParser import FileParser
from ..NgramsExtractors import *
......@@ -23,8 +24,8 @@ class EuropressFileParser(FileParser):
#print(len(contents))
#return []
encoding = self.detect_encoding(contents)
print(encoding)
if encoding != "utf-8":
#print(encoding)
#if encoding != "utf-8":
contents = contents.decode(encoding, errors='replace').encode(codif)
try:
......@@ -78,12 +79,17 @@ class EuropressFileParser(FileParser):
text = text.replace('ű', 'û')
text = text.replace(' aot ', ' août ')
try :
metadata['publication_date'] = datetime.strptime(text, '%d %B %Y')
except :
try:
metadata['publication_date'] = datetime.strptime(text, '%B %Y')
except :
try:
metadata['publication_date'] = dateutil.parser.parse(text)
except Exception as error:
print(error)
print(text)
pass
......
......@@ -93,7 +93,7 @@
<script type="text/javascript">
(function($) {
$(window).load(function(){ $('#id_username').focus(); });
$(window).load(function(){ $('#username').focus(); });
})(grp.jQuery);
</script>
</body>
......
......@@ -43,7 +43,7 @@
<li><a tabindex="-1" href="/auth/">Login</a></li>
<li><a tabindex="-1" href="#">Profile</a></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#">Help</a></li>
<li><a tabindex="-1" href="/auth/logout">Logout</a></li>
</ul>
</li>
</ul>
......
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