Commit a45d8db1 authored by Administrator's avatar Administrator

Merge branch 'testing'

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