Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	setup.py
  • Loading branch information
mmarcos committed Jan 22, 2019
2 parents a40dde6 + c4ca4e6 commit c2526e6
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 11 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
Always reference the ticket number at the end of the issue description.


## 1.3.6 (2019-01-22)

### Fixed

- Do not logout logged-in users which visit the login view, but redirect them to home
- Set the correct language in the html tag


## 1.3.5 (2018-12-21)

### Fixed
Expand Down
13 changes: 12 additions & 1 deletion arctic/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,12 @@ def get_context_data(self, **kwargs):
return context

def get(self, request, *args, **kwargs):
logout(request)
# If the logout url is the login url, log the user out of the system
if settings.LOGOUT_URL == settings.LOGIN_URL:
logout(request)
# Else redirect a logged in user to the homepage
elif request.user.is_authenticated:
return redirect("/")
return super(LoginView, self).get(request, *args, **kwargs)

def post(self, request, *args, **kwargs):
Expand All @@ -932,3 +937,9 @@ def post(self, request, *args, **kwargs):
return render(
request, self.template_name, self.get_context_data(**kwargs)
)


class LogoutView(View):
def dispatch(self, request, *args, **kwargs):
logout(request)
return redirect(settings.LOGIN_URL)
3 changes: 2 additions & 1 deletion arctic/project_template/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@

STATIC_URL = "/static/"

LOGIN_URL = LOGOUT_URL = "login"
LOGIN_URL = "login"
LOGOUT_URL = "logout"

# Arctic configuration
ARCTIC_SITE_NAME = "{{ project_name }}'s Arctic website"
Expand Down
8 changes: 4 additions & 4 deletions arctic/static/arctic/src/assets/js/components/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function django2datepicker(django_format) {
}

function datetimeformatter(django_date, format) {
var date_valid = moment(django_date).isValid();
var date_valid = moment(django_date, format).isValid();
if (!date_valid) {
return null;
} else {
Expand Down Expand Up @@ -127,7 +127,7 @@ $(document).ready(function() {
$.fn.datepicker.language['en'] = datetime_picker_settings;

$('[js-datepicker]').each(function(index) {
var date = datetimeformatter($(this).attr("data-date"), datetime_picker_settings.dateFormat);
var date = datetimeformatter($(this).attr("data-date"), $(this).attr('format') ? $(this).attr('format') : datetime_picker_settings.dateFormat);
var instance = this;
$(instance).attr('type', 'text');
$(instance).datepicker({
Expand All @@ -151,7 +151,7 @@ $(document).ready(function() {
});

$('[js-timepicker]').each(function(index) {
var date = datetimeformatter($(this).attr("data-time"), datetime_picker_settings.timeFormat);
var date = datetimeformatter($(this).attr("data-date"), $(this).attr('format') ? $(this).attr('format') : datetime_picker_settings.timeFormat);
var instance = this;
$(instance).attr('type', 'text');
$(instance).datepicker({
Expand All @@ -175,7 +175,7 @@ $(document).ready(function() {
});

$('[js-datetimepicker]').each(function(index) {
var date = datetimeformatter($(this).attr("data-datetime"), `${datetime_picker_settings.dateFormat} ${datetime_picker_settings.timeFormat}`);
var date = datetimeformatter($(this).attr("data-datetime"), $(this).attr('format') ? $(this).attr('format') : `${datetime_picker_settings.dateFormat} ${datetime_picker_settings.timeFormat}`);
var instance = this;
$(instance).attr('type', 'text');
$(instance).datepicker({
Expand Down
4 changes: 2 additions & 2 deletions arctic/templates/arctic/base.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% load i18n staticfiles arctic_tags %}

{% get_current_language as LANGUAGE_CODE %}
<!DOCTYPE html>
<html lang="en">
<html lang="{{ LANGUAGE_CODE }}">

<head>
{% include "arctic/partials/head.html" %}
Expand Down
4 changes: 4 additions & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ Being a pure Django settings, LOGIN_URL and LOGOUT_URL used in Arctic to display
login and logout links. Both items supposed to be names of URLs. Defaults are 'login'
and 'logout'. Could be set to `None` if you don't want to use authentication in your app.

If the LOGIN_URL and LOGOUT_URL are the same, the LoginView will automatically logout
the user when he visits the login page. If they are different, a logged in user will be
redirected to the homepage of the CMS and not be logged out.

# Generic Class Based Views

Arctic provides a number of class based views that add integration with the
Expand Down
3 changes: 2 additions & 1 deletion example/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
MEDIA_ROOT = location("media")
MEDIA_URL = "/media/"

LOGIN_URL = LOGOUT_URL = "login"
LOGIN_URL = "login"
LOGOUT_URL = "logout"


try:
Expand Down
3 changes: 2 additions & 1 deletion example/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.conf.urls import include, url
from django.conf.urls.static import static

from arctic.generics import LoginView
from arctic.generics import LoginView, LogoutView
from arctic.views import handler400, handler403, handler404, handler500 # noqa

from countries.views import CountryAPIView, CountryListView
Expand All @@ -14,6 +14,7 @@
urlpatterns = [
url(r"^$", DashboardView.as_view(), name="index"),
url(r"^login/$", LoginView.as_view(), name="login"),
url(r"^logout/$", LogoutView.as_view(), name="logout"),
url(r"^articles/", include("articles.urls", "articles")),
url(r"^users/", include("arctic.users.urls", namespace="users")),
url(r"^countries/$", CountryListView.as_view(), name="countries-list"),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from setuptools import find_packages, setup

__VERSION__ = "1.3.5"
__VERSION__ = "1.3.6"


def read_md(f):
Expand Down

0 comments on commit c2526e6

Please sign in to comment.