From f5e8826ba8f8fa9a34dcf621212ed0863a066e9a Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Wed, 15 Jan 2014 17:12:24 -0800 Subject: [PATCH] Styling login and authorize oauth templates. --- apps/reader/urls.py | 6 +- apps/reader/views.py | 4 +- media/css/payments.css | 17 ++++-- media/css/reader.css | 61 +++++++++++++++++-- settings.py | 12 +++- templates/accounts/login.html | 33 +++++----- .../application_confirm_delete.html | 19 ++++++ .../oauth2_provider/application_detail.html | 42 +++++++++++++ .../oauth2_provider/application_form.html | 43 +++++++++++++ .../oauth2_provider/application_list.html | 20 ++++++ .../application_registration_form.html | 10 +++ templates/oauth2_provider/authorize.html | 47 ++++++++++++++ templates/reader/welcome.xhtml | 8 ++- urls.py | 3 + 14 files changed, 290 insertions(+), 35 deletions(-) create mode 100644 templates/oauth2_provider/application_confirm_delete.html create mode 100644 templates/oauth2_provider/application_detail.html create mode 100644 templates/oauth2_provider/application_form.html create mode 100644 templates/oauth2_provider/application_list.html create mode 100644 templates/oauth2_provider/application_registration_form.html create mode 100644 templates/oauth2_provider/authorize.html diff --git a/apps/reader/urls.py b/apps/reader/urls.py index 0daeabeda..48665270f 100644 --- a/apps/reader/urls.py +++ b/apps/reader/urls.py @@ -4,10 +4,10 @@ from apps.reader import views urlpatterns = patterns('', url(r'^$', views.index), url(r'^login_as', views.login_as, name='login_as'), - url(r'^logout', views.logout, name='logout'), - url(r'^login', views.login, name='login'), + url(r'^logout', views.logout, name='welcome-logout'), + url(r'^login', views.login, name='welcome-login'), url(r'^autologin/(?P\w+)/(?P\w+)/?', views.autologin, name='autologin'), - url(r'^signup', views.signup, name='signup'), + url(r'^signup', views.signup, name='welcome-signup'), url(r'^feeds/?$', views.load_feeds, name='load-feeds'), url(r'^feed/(?P\d+)', views.load_single_feed, name='load-single-feed'), url(r'^page/(?P\d+)', views.load_feed_page, name='load-feed-page'), diff --git a/apps/reader/views.py b/apps/reader/views.py index a5dc04157..4db0227cb 100644 --- a/apps/reader/views.py +++ b/apps/reader/views.py @@ -23,6 +23,7 @@ from django.core.mail import EmailMultiAlternatives from django.contrib.sites.models import Site from django.utils import feedgenerator from mongoengine.queryset import OperationError +from oauth2_provider.decorators import protected_resource from apps.recommendations.models import RecommendedFeed from apps.analyzer.models import MClassifierTitle, MClassifierAuthor, MClassifierFeed, MClassifierTag from apps.analyzer.models import apply_classifier_titles, apply_classifier_feeds @@ -743,8 +744,7 @@ def load_feed_page(request, feed_id): logging.user(request, "~FYLoading original page, from the db") return HttpResponse(data, mimetype="text/html; charset=utf-8") - -@login_required() + @json.json_view def load_starred_stories(request): user = get_user(request) diff --git a/media/css/payments.css b/media/css/payments.css index d26105edb..5580414ac 100644 --- a/media/css/payments.css +++ b/media/css/payments.css @@ -58,14 +58,19 @@ .NB-static-form input, .NB-static-form select { - margin: 6px 0 2px; - width: 200px; font-size: 14px; padding: 2px; - border: 1px solid #606060; - -moz-box-shadow:2px 2px 0 #A0B998; - -webkit-box-shadow:2px 2px 0 #A0B998; - box-shadow:2px 2px 0 #A0B998; + margin: 6px 4px; + border: 1px solid rgba(0, 0, 0, .2); + border-radius: 1px; + -moz-box-shadow: inset 0 2px 2px rgba(50, 50, 50, 0.15); + box-shadow: inset 0 2px 2px rgba(50, 50, 50, 0.15); + + width: 200px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + } .NB-static-form input.error, diff --git a/media/css/reader.css b/media/css/reader.css index a9dbb5e43..546421584 100644 --- a/media/css/reader.css +++ b/media/css/reader.css @@ -4069,9 +4069,9 @@ form.opml_import_form input { .NB-splash-info .NB-splash-title { position: absolute; bottom: -1px; - height: 55px; + width: 282px; + height: 54px; right: 166px; - width: 312px; z-index: 2; } @@ -4079,8 +4079,8 @@ form.opml_import_form input { top: 0px; bottom: inherit; right: 24px; - width: 312px; - height: 55px; + width: 282px; + height: 54px; } .NB-body-main .NB-splash-info.NB-splash-top .NB-splash-title { display: none; @@ -8607,6 +8607,9 @@ form.opml_import_form input { color: #303030; line-height: 18px; } +.NB-static h3 { + line-height: 1.4em; +} .NB-static .NB-splash-info { opacity: .9; @@ -10201,6 +10204,56 @@ form.opml_import_form input { margin-left: 200px; } +/* =============== */ +/* = OAuth Forms = */ +/* =============== */ + +.NB-static-oauth h3 { + margin-top: 0; + text-align: center; +} + +.NB-static-oauth .NB-static-form { + width: 500px; + margin: 24px auto; +} +.NB-static-login .NB-static-form { + width: 360px; +} +.NB-static-oauth .NB-static-form-label label { + width: 120px; + text-transform: uppercase; + font-size: 18px; + padding: 8px 0 0 0; + color: rgba(0, 0, 0, .6); +} +.NB-static-oauth .NB-static-form-input input { + margin-left: 0; + margin-right: 0; + height: 34px; + font-size: 22px; +} + +.NB-static-oauth input[type=submit].NB-static-form-submit { + margin: 24px 0 0 0; + font-size: 26px; + font-size: 18px; + padding: 8px 12px; +} +.NB-static-login input[type=submit].NB-static-form-submit { + margin: 12px 0 0 120px; +} +.NB-static-oauth .NB-error { + font-size: 12px; + text-align: center; + color: #6A1000; + padding: 4px 0 0; + line-height: 14px; + font-weight: bold; + clear: both; +} + + /* ======================== */ /* = Feed Options Popover = */ /* ======================== */ diff --git a/settings.py b/settings.py index 5fd7b5b63..60c5e2a9c 100644 --- a/settings.py +++ b/settings.py @@ -64,7 +64,7 @@ LANGUAGE_CODE = 'en-us' SITE_ID = 1 USE_I18N = False LOGIN_REDIRECT_URL = '/' -LOGIN_URL = '/reader/login' +LOGIN_URL = '/account/login' MEDIA_URL = '/media/' STATIC_URL = '/media/' STATIC_ROOT = '/media/' @@ -122,6 +122,16 @@ AUTHENTICATION_BACKENDS = ( CORS_ORIGIN_ALLOW_ALL = True +OAUTH2_PROVIDER = { + 'SCOPES': { + 'read': 'Read: saved stories, shared stories, tags, training, and feeds', + 'write': 'Write: saving stories, sharing stories, adding tags, adding training, feed management', + }, + + 'CLIENT_ID_GENERATOR_CLASS': 'oauth2_provider.generators.ClientIdGenerator', + +} + # =========== # = Logging = # =========== diff --git a/templates/accounts/login.html b/templates/accounts/login.html index e05faa497..3536c51d2 100644 --- a/templates/accounts/login.html +++ b/templates/accounts/login.html @@ -2,7 +2,7 @@ {% load typogrify_tags utils_tags zebra_tags %} -{% block bodyclass %}NB-static NB-static-login{% endblock %} +{% block bodyclass %}NB-static NB-static-oauth NB-static-login{% endblock %} {% block extra_head_js %} {% include_stylesheets "common" %} {% endblock %} @@ -11,26 +11,25 @@ {% block content %} +
+ Login +
+
+
+ {% if form.errors %} +

Your username and password didn't match.
Please try again.

+ {% else %}{% if next %} +

Please login to continue.

+ {% endif %}{% endif %} - {% if form.errors %} -

Your username and password didn't match. Please try again.

- {% endif %} - - {% csrf_token %} - - - - - - - - - -
{{ form.username.label_tag }}{{ form.username }}
{{ form.password.label_tag }}{{ form.password }}
+
{{ form.username.label_tag }}
+
{{ form.username }}
+
{{ form.password.label_tag }}
+
{{ form.password }}
- +
diff --git a/templates/oauth2_provider/application_confirm_delete.html b/templates/oauth2_provider/application_confirm_delete.html new file mode 100644 index 000000000..1651f5177 --- /dev/null +++ b/templates/oauth2_provider/application_confirm_delete.html @@ -0,0 +1,19 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% load url from future %} +{% block content %} +
+

{% trans "Are you sure to delete the application" %} {{ application.name }}?

+
+ {% csrf_token %} + + +
+
+{% endblock content %} \ No newline at end of file diff --git a/templates/oauth2_provider/application_detail.html b/templates/oauth2_provider/application_detail.html new file mode 100644 index 000000000..36eb583a1 --- /dev/null +++ b/templates/oauth2_provider/application_detail.html @@ -0,0 +1,42 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% load url from future %} +{% block content %} +
+

{{ application.name }}

+ +
    +
  • +

    {% trans "Client id" %}

    + +
  • + +
  • +

    {% trans "Client secret" %}

    + +
  • + +
  • +

    {% trans "Client type" %}

    +

    {{ application.client_type }}

    +
  • + +
  • +

    {% trans "Authorization Grant Type" %}

    +

    {{ application.authorization_grant_type }}

    +
  • + +
  • +

    {% trans "Redirect Uris" %}

    + +
  • +
+ + +
+{% endblock content %} \ No newline at end of file diff --git a/templates/oauth2_provider/application_form.html b/templates/oauth2_provider/application_form.html new file mode 100644 index 000000000..baa81a1b5 --- /dev/null +++ b/templates/oauth2_provider/application_form.html @@ -0,0 +1,43 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% load url from future %} +{% block content %} +
+
+

+ {% block app-form-title %} + {% trans "Edit application" %} {{ application.name }} + {% endblock app-form-title %} +

+ {% csrf_token %} + + {% for field in form %} +
+ +
+ {{ field }} + {% for error in field.errors %} + {{ error }} + {% endfor %} +
+
+ {% endfor %} + +
+ {% for error in form.non_field_errors %} + {{ error }} + {% endfor %} +
+ + +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/oauth2_provider/application_list.html b/templates/oauth2_provider/application_list.html new file mode 100644 index 000000000..c50049308 --- /dev/null +++ b/templates/oauth2_provider/application_list.html @@ -0,0 +1,20 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% load url from future %} +{% block content %} +
+

{% trans "Your applications" %}

+ {% if applications %} + + + New Application + {% else %} +

{% trans "No applications defined" %}. {% trans "Click here" %} {% trans "if you want to register a new one" %}

+ {% endif %} +
+{% endblock content %} \ No newline at end of file diff --git a/templates/oauth2_provider/application_registration_form.html b/templates/oauth2_provider/application_registration_form.html new file mode 100644 index 000000000..077e2315d --- /dev/null +++ b/templates/oauth2_provider/application_registration_form.html @@ -0,0 +1,10 @@ +{% extends "oauth2_provider/application_form.html" %} + +{% load i18n %} +{% load url from future %} + +{% block app-form-title %}{% trans "Register a new application" %}{% endblock app-form-title %} + +{% block app-form-action-url %}{% url 'oauth2_provider:register' %}{% endblock app-form-action-url %} + +{% block app-form-back-url %}{% url "oauth2_provider:list" %}"{% endblock app-form-back-url %} \ No newline at end of file diff --git a/templates/oauth2_provider/authorize.html b/templates/oauth2_provider/authorize.html new file mode 100644 index 000000000..77f5a5134 --- /dev/null +++ b/templates/oauth2_provider/authorize.html @@ -0,0 +1,47 @@ +{% extends "base.html" %} + +{% block bodyclass %}NB-static NB-static-oauth{% endblock %} + +{% load i18n %} +{% block content %} + +
+ Authorize {{ application.name }} +
+ +
+ {% if not error %} +
+

{{ application.name }} would like to access your NewsBlur account

+ {% csrf_token %} + + {% for field in form %} + {% if field.is_hidden %} + {{ field }} + {% endif %} + {% endfor %} + +

{{ application.name }} is requesting these permissions:

+
    + {% for scope in scopes_descriptions %} +
  • {{ scope }}
  • + {% endfor %} +
+ + {{ form.errors }} + {{ form.non_field_errors }} + +
+
+ + +
+
+
+ + {% else %} +

Error: {{ error.error }}

+

{{ error.description }}

+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/templates/reader/welcome.xhtml b/templates/reader/welcome.xhtml index 0ed550082..868f5db87 100644 --- a/templates/reader/welcome.xhtml +++ b/templates/reader/welcome.xhtml @@ -70,7 +70,9 @@