diff options
-rw-r--r-- | askbot/conf/external_keys.py | 16 | ||||
-rw-r--r-- | askbot/conf/login_providers.py | 4 | ||||
-rw-r--r-- | askbot/deps/django_authopenid/util.py | 34 | ||||
-rw-r--r-- | askbot/deps/django_authopenid/views.py | 24 | ||||
-rwxr-xr-x | askbot/media/jquery-openid/images/google.gif | bin | 1528 -> 3391 bytes | |||
-rw-r--r-- | askbot/media/jquery-openid/jquery.openid.js | 21 | ||||
-rw-r--r-- | askbot/media/style/style.css | 2 | ||||
-rw-r--r-- | askbot/media/style/style.less | 2 | ||||
-rw-r--r-- | askbot/since-aug1.txt | 43 | ||||
-rw-r--r-- | askbot/templates/badge.html | 6 | ||||
-rw-r--r-- | askbot/templates/macros.html | 6 | ||||
-rw-r--r-- | askbot/templates/user_profile/user_network.html | 16 | ||||
-rw-r--r-- | askbot/templates/users.html | 6 | ||||
-rw-r--r-- | askbot/templates/widgets/user_long_score_and_badge_summary.html | 4 | ||||
-rw-r--r-- | askbot/templates/widgets/user_navigation.html | 11 |
15 files changed, 136 insertions, 59 deletions
diff --git a/askbot/conf/external_keys.py b/askbot/conf/external_keys.py index 989cbf46..f45c9786 100644 --- a/askbot/conf/external_keys.py +++ b/askbot/conf/external_keys.py @@ -78,6 +78,22 @@ settings.register( settings.register( livesettings.StringValue( EXTERNAL_KEYS, + 'GOOGLE_PLUS_KEY', + description=_('Google+ public API key') + ) +) + +settings.register( + livesettings.StringValue( + EXTERNAL_KEYS, + 'GOOGLE_PLUS_SECRET', + description=_('Google+ secret API key') + ) +) + +settings.register( + livesettings.StringValue( + EXTERNAL_KEYS, 'FACEBOOK_KEY', description=_('Facebook public API key'), help_text=_( diff --git a/askbot/conf/login_providers.py b/askbot/conf/login_providers.py index fad29687..e664fe52 100644 --- a/askbot/conf/login_providers.py +++ b/askbot/conf/login_providers.py @@ -126,7 +126,7 @@ providers = ( 'ClaimID', 'Facebook', 'Flickr', - 'Google', + 'Google Plus', 'Mozilla Persona', 'Twitter', 'LinkedIn', @@ -144,7 +144,7 @@ providers = ( DISABLED_BY_DEFAULT = ('LaunchPad', 'Mozilla Persona') -NEED_EXTRA_SETUP = ('Twitter', 'Facebook', 'LinkedIn', 'identi.ca',) +NEED_EXTRA_SETUP = ('Google Plus', 'Twitter', 'Facebook', 'LinkedIn', 'identi.ca',) for provider in providers: if provider == 'local': diff --git a/askbot/deps/django_authopenid/util.py b/askbot/deps/django_authopenid/util.py index 586136d6..f05aba31 100644 --- a/askbot/deps/django_authopenid/util.py +++ b/askbot/deps/django_authopenid/util.py @@ -429,7 +429,6 @@ def get_enabled_major_login_providers(): 'get_user_id_function': get_facebook_user_id, 'response_parser': lambda data: dict(urlparse.parse_qsl(data)), 'scope': ['email',], - } if askbot_settings.TWITTER_KEY and askbot_settings.TWITTER_SECRET: data['twitter'] = { @@ -496,13 +495,22 @@ def get_enabled_major_login_providers(): 'icon_media_path': '/jquery-openid/images/linkedin.gif', 'get_user_id_function': get_linked_in_user_id } - data['google'] = { - 'name': 'google', - 'display_name': 'Google', - 'type': 'openid-direct', - 'icon_media_path': '/jquery-openid/images/google.gif', - 'openid_endpoint': 'https://www.google.com/accounts/o8/id', - } + + def get_google_user_id(client): + return client.request('me')['id'] + + if askbot_settings.GOOGLE_PLUS_KEY and askbot_settings.GOOGLE_PLUS_SECRET: + data['google-plus'] = { + 'name': 'google-plus', + 'display_name': 'Google', + 'type': 'oauth2', + 'auth_endpoint': 'https://accounts.google.com/o/oauth2/auth', + 'token_endpoint': 'https://accounts.google.com/o/oauth2/token', + 'resource_endpoint': 'https://www.googleapis.com/plus/v1/people/', + 'icon_media_path': '/jquery-openid/images/google.gif', + 'get_user_id_function': get_google_user_id, + 'extra_auth_params': {'scope': ('profile', 'email', 'openid'), 'openid.realm': askbot_settings.APP_URL} + } data['mozilla-persona'] = { 'name': 'mozilla-persona', 'display_name': 'Mozilla Persona', @@ -849,14 +857,14 @@ def get_oauth2_starter_url(provider_name, csrf_token): providers = get_enabled_login_providers() params = providers[provider_name] - client_id = getattr(askbot_settings, provider_name.upper() + '_KEY') + client_id = getattr(askbot_settings, provider_name.replace('-', '_').upper() + '_KEY') redirect_uri = site_url(reverse('user_complete_oauth2_signin')) client = Client( auth_endpoint=params['auth_endpoint'], client_id=client_id, redirect_uri=redirect_uri ) - return client.auth_uri(state=csrf_token, scope=params['scope']) + return client.auth_uri(state=csrf_token, **params.get('extra_auth_params', {})) def ldap_check_password(username, password): @@ -892,3 +900,9 @@ def mozilla_persona_get_email_from_assertion(assertion): raise ImproperlyConfigured(message) #todo: nead more feedback to help debug fail cases return None + +def google_migrate_from_openid_to_gplus(openid_url, gplus_id): + from askbot.deps.django_authopenid.models import UserAssociation + assoc = UserAssociation.object.filter(openid_url=openid_url) + assoc.update(openid_url=str(gplus_id), provider_name='google-plus') + diff --git a/askbot/deps/django_authopenid/views.py b/askbot/deps/django_authopenid/views.py index e1a3b981..1b3e5161 100644 --- a/askbot/deps/django_authopenid/views.py +++ b/askbot/deps/django_authopenid/views.py @@ -292,14 +292,15 @@ def complete_oauth2_signin(request): params = providers[provider_name] assert(params['type'] == 'oauth2') + name_token = provider_name.replace('-', '_').upper() client_id = getattr( askbot_settings, - provider_name.upper() + '_KEY', + name_token + '_KEY', ) client_secret = getattr( askbot_settings, - provider_name.upper() + '_SECRET', + name_token + '_SECRET', ) client = OAuth2Client( @@ -320,9 +321,9 @@ def complete_oauth2_signin(request): user_id = params['get_user_id_function'](client) user = authenticate( - oauth_user_id = user_id, - provider_name = provider_name, - method = 'oauth' + oauth_user_id=user_id, + provider_name=provider_name, + method='oauth' ) logging.debug('finalizing oauth signin') @@ -330,10 +331,21 @@ def complete_oauth2_signin(request): request.session['email'] = ''#todo: pull from profile request.session['username'] = ''#todo: pull from profile - if (provider_name == 'facebook'): + if provider_name == 'facebook': profile = client.request("me") request.session['email'] = profile.get('email', '') request.session['username'] = profile.get('username', '') + elif provider_name == 'google-plus' and user is None: + #attempt to migrate user from the old OpenId protocol + openid_url = getattr(client, 'openid_id', None) + if openid_url: + msg_tpl = 'trying to migrate user %d from OpenID %s to g-plus %s' + logging.critical(msg_tpl, (user.id, str(openid_url), str(user_id))) + user = authenticate(openid_url=openid_url) + if user: + util.google_migrate_from_openid_to_gplus(openid_url, user_id) + logging.critical('migrated login from OpenID to g-plus') + return finalize_generic_signin( request = request, diff --git a/askbot/media/jquery-openid/images/google.gif b/askbot/media/jquery-openid/images/google.gif Binary files differindex 65395365..df9f7f76 100755 --- a/askbot/media/jquery-openid/images/google.gif +++ b/askbot/media/jquery-openid/images/google.gif diff --git a/askbot/media/jquery-openid/jquery.openid.js b/askbot/media/jquery-openid/jquery.openid.js index 34d6e91b..f2b985f1 100644 --- a/askbot/media/jquery-openid/jquery.openid.js +++ b/askbot/media/jquery-openid/jquery.openid.js @@ -1,3 +1,11 @@ +var renderGooglePlusBtn = function() { + gapi.signin.render('google-plus-btn-id', { + 'clientid': askbot['settings']['googlePlusPublicKey'], + 'cookiepolicy': 'single_host_origin', + 'scope': 'https://www.googleapis.com/auth/plus.login' + }); +}; + $.fn.authenticator = function() { var signin_page = $(this); var signin_form = $('#signin-form'); @@ -405,6 +413,19 @@ $.fn.authenticator = function() { }); }; + var activateGooglePlusBtn = function(btn) { + //add id to button - so that the "render" call would find it + btn.attr('id', 'google-plus-btn-id'); + //load script with the gplus button code + var po = document.createElement('script'); + po.type = 'text/javascript'; + po.async = true; + //the global function renderGooglePlusBtn defined above will activate the button + po.src = 'https://apis.google.com/js/client:plusone.js?onload=renderGooglePlusBtn'; + var s = document.getElementsByTagName('script')[0]; + s.parentNode.insertBefore(po, s); + }; + var setup_default_handlers = function(){ setup_event_handlers( signin_page.find('input.openid-direct'), diff --git a/askbot/media/style/style.css b/askbot/media/style/style.css index c2223d9c..38c1d0b0 100644 --- a/askbot/media/style/style.css +++ b/askbot/media/style/style.css @@ -1147,7 +1147,7 @@ body.anon.ask-page .search-drop-menu { width: 52px; padding-left: 2px; padding-top: 3px; - background: #ffffff url(../images/feed-icon-small.png) no-repeat center right; + background: url(../images/feed-icon-small.png) no-repeat center right; float: right; font-family: Georgia, serif; font-size: 16px; diff --git a/askbot/media/style/style.less b/askbot/media/style/style.less index 749d9ce4..42ed7b44 100644 --- a/askbot/media/style/style.less +++ b/askbot/media/style/style.less @@ -1191,7 +1191,7 @@ body.anon.ask-page .search-drop-menu { width:52px; padding-left: 2px; padding-top:3px; - background:#fff url(../images/feed-icon-small.png) no-repeat center right; + background: url(../images/feed-icon-small.png) no-repeat center right; float:right; font-family: @sort-font; font-size:16px; diff --git a/askbot/since-aug1.txt b/askbot/since-aug1.txt new file mode 100644 index 00000000..acd408b8 --- /dev/null +++ b/askbot/since-aug1.txt @@ -0,0 +1,43 @@ +3 fca986245b0c87891ed62e54505cbe342bce9f8c applied patch to send email alerts when edit is approved by moderator +3 fe6c542ddecae347b5d0b3e5fce2247367938272 allowed users to edit moderated posts +3 5c45cc1d2de7907bdf1df58e736acac39dfe04e1 made change language link to keep user on the same page after switching the language +0.1 98a36e933b1d99001640e042039ad644df11643b used more broad regex for the fakepath issue solution +JP 3696ce09d1cef7871f21f3b654541d514267af07 Merge pull request #301 from knowledgepoint-devs/merge1 +JP 889e42c1ac04c1b195529c04459ffcbdacec5a3b Fix for fakepath issue https://trello.com/c/ESlli63m/456-fakepath-issue-in-attachments. +1 b53d2a18c3992db17636d68d10df6b1892a11be2 converted preferred languages switches to checkboxes and added default language selector +0.2 6af996d64c68e3ead6b33b850d1102b2a373e47a fixed language of the url in the user-lang language mode +0.1 30b965b2fc6797e0b9c80d74232bb79b241a747a fixed redirect url on the select languages view +0.7 cd0ad19c7e2cd095f38cc7523bab8173a6643f4e made languages selection tab +0.2 c2977501bc0c21e606e6bb8d14682dde4d13e77a add/remove anon class to body on log out/in +0.1 bde7d445dd9b05362b417d28aa100526e833709e removed a pdb statement +0 fe56ccdcf376ca63eb1822a3f0cc5104bef2e9e3 Merge branch 'merge1' of github.com:ASKBOT/askbot-devel into merge1 +0.1 7e14d5521363ea96fbf7b5e3b2cea2e8252a7b35 bugfixes in account recovery and moderation post rejection +0.2 f08d009d7d22a978dfa16c437c6e175dad59f4db bugfixes in account recovery and moderation post rejection +0.2 e2fda13e41840dca99f0d99beaf7c185372dcf2f bugfix for rejection with reason +0.2 c92960618f7fa75d9207fdc1955356683b2b8b59 fixed typo in the function name in js +0.1 b94542bfccb0f9427dd136ab917b195f6126e7f3 added default values to the ASKBOT_SITE_PROTOCOLS +10 c84c4bdc72bdcd7b969457225c551a4462e93c88 merged with another branch +20 3bd441cb50351e27a0d8f5f4de932175d7423d2d merged with the master branch +0.5 04e602310bae423ea1d4034400085a03f4a21ca6 email for moderation responses and instant alerts in the primary language of the user +JP 5b8844a84627129d8cbfb6ac6f80144eb49cd45a Merge pull request #295 from knowledgepoint-devs/merge1 +0.5 55bdb242a95abf665b9265f83392a7856a8ecbdb allowed customization of image width parameters +0.1 26889b071a0196312947ead2b80f9a941deb13c0 bugfix to fix_question_tags command +0.3 4e335aa13b3a396a492c11dfd69976b503765c88 allowed extra emails and change interval for the alert_admins_of_active_users +JP b3d410ca19090f28923987dea5a1f015a6cea873 Made following changes to admin screens: * added language column and filter to list views for User, Thread and Post models. * added column to Post list view showing the first 30 chars of the Post's text * added site column and filter to list view for Thread model * general tidying (including removing debug print statements and moving filters with long lookup lists to bottom of list of filters) +0.3 960b90a29fb29d5c861fbd99e803c98613ceb244 fixed erroneous switch of language upon question asking +0.3 fbebae0c2a7d85538ce10215a1cba35d9104d40f added command clear_cache and a small change in the urls.py template +0.1 3db83c5f0cf26ce934aa0de8067fa57e043080bd rebuilt source locale +0.25 de082b2bc11410fb65e2656c83d115770d5a63ec updated locales from Transifex +0.1 e3f91ade727dc28d8a6765d6af82a966a990f671 fixed typo in the html tag +0.1 85315ee04606a9bb0fc9a3197f53493b9769e060 removed unused file +0.2 160acba53f192138b3c35bfe41c98b2488b18fd9 fixed issue when asking with groups and premoderation enabled +0.1 60817f48345016a222e26b5fdfbe4075c8fe7375 fixed bug when asking with moderation and groups enabled +0.5 c9212a856b5adb645a8c9f3636f3c4ab29747b92 changes to the language and groups dropdown menues +3 fcff2c90e5d7b7d6e064620a515819d4186178d4 first pass for the implementation of three language modes +2 bd33c8f73b493c3ba3490f9f43b043df311336bb improved the question sharing widget +0.3 f739ee80b595eec9649218bc89779b159cad75b1 banished the MARKUP_CODE_FRIENDLY option and hardcoded it as True +0.25 9f5537102b00c444bdf8ce061bc4cde69873605e improvement of comment rendering in js + +Sum = 51 + +Worked on 18 different days - 54h diff --git a/askbot/templates/badge.html b/askbot/templates/badge.html index 4a405218..25bda5ea 100644 --- a/askbot/templates/badge.html +++ b/askbot/templates/badge.html @@ -16,11 +16,7 @@ </div> <div class="clean"></div> <div id="award-list"> - {{ macros.user_list( - badge_recipients, - karma_mode=settings.KARMA_MODE, - badges_mode=settings.BADGES_MODE - )}} + {{ macros.user_list(badge_recipients) }} </div> {% endblock %} <!-- end template badge.html --> diff --git a/askbot/templates/macros.html b/askbot/templates/macros.html index 5647d8d6..f0fe368e 100644 --- a/askbot/templates/macros.html +++ b/askbot/templates/macros.html @@ -582,9 +582,7 @@ for the purposes of the AJAX comment editor #} {% endif %} {%- endmacro -%} -{%- macro user_long_score_and_badge_summary( - user, karma_mode=None, badges_mode = None -) -%} +{%- macro user_long_score_and_badge_summary(user) -%} {%- include "widgets/user_long_score_and_badge_summary.html" -%} {%- endmacro -%} @@ -630,7 +628,7 @@ for the purposes of the AJAX comment editor #} {% include "widgets/user_card.html" %} {% endmacro %} -{%- macro user_list(users, karma_mode=None, badges_mode=None) -%} +{%- macro user_list(users) -%} {% include "widgets/user_list.html" %} {%- endmacro -%} diff --git a/askbot/templates/user_profile/user_network.html b/askbot/templates/user_profile/user_network.html index ce13d5c4..c4006392 100644 --- a/askbot/templates/user_profile/user_network.html +++ b/askbot/templates/user_profile/user_network.html @@ -8,23 +8,11 @@ {% if followed_users or followers %} {% if followers %} <h2>{% trans count=followers|length %}Followed by {{count}} person{% pluralize count %}Followed by {{count}} people{% endtrans %}</h2> - {{ - macros.user_list( - followers, - karma_mode = settings.KARMA_MODE, - badges_mode = settings.BADGES_MODE - ) - }} + {{ macros.user_list(followers) }} {% endif %} {% if followed_users %} <h2>{% trans count=followed_users|length %}Following {{count}} person{% pluralize count %}Following {{count}} people{% endtrans %}</h2> - {{ - macros.user_list( - followed_users, - karma_mode = settings.KARMA_MODE, - badges_mode = settings.BADGES_MODE - ) - }} + {{ macros.user_list(followed_users) }} {% endif %} {% else %} {% if request.user == view_user %} diff --git a/askbot/templates/users.html b/askbot/templates/users.html index 23c1f443..1f5cb631 100644 --- a/askbot/templates/users.html +++ b/askbot/templates/users.html @@ -68,11 +68,7 @@ {% if not users.object_list %} <p><span>{% trans %}Nothing found.{% endtrans %}</span></p> {% endif %} -{{ macros.user_list( - users.object_list, - karma_mode = settings.KARMA_MODE, badges_mode = settings.BADGES_MODE - ) -}} +{{ macros.user_list(users.object_list) }} <div class="pager"> {{ macros.paginator(paginator_context) }} </div> diff --git a/askbot/templates/widgets/user_long_score_and_badge_summary.html b/askbot/templates/widgets/user_long_score_and_badge_summary.html index dc93987c..76e5d4d4 100644 --- a/askbot/templates/widgets/user_long_score_and_badge_summary.html +++ b/askbot/templates/widgets/user_long_score_and_badge_summary.html @@ -2,12 +2,12 @@ {%- if user.is_read_only() -%} {% trans %}read only access{% endtrans %} {%- else -%} - {%- if karma_mode != 'hidden' -%} + {%- if settings.KARMA_MODE != 'hidden' -%} <a class="user-micro-info reputation" href="{{user.get_absolute_url()}}?sort=reputation" data-url="{% url 'get_perms_data' %}" - >{% trans %}karma:{% endtrans %} {{user.reputation}}</a>{% if badges_mode == 'public' and have_badges %}, {% endif -%} + >{% trans %}karma:{% endtrans %} {{user.reputation}}</a>{% if settings.BADGES_MODE == 'public' and have_badges %}, {% endif -%} {%- endif -%} {%- if badges_mode == 'public' and have_badges -%} <a class="user-micro-info" diff --git a/askbot/templates/widgets/user_navigation.html b/askbot/templates/widgets/user_navigation.html index d451e65b..97c42da2 100644 --- a/askbot/templates/widgets/user_navigation.html +++ b/askbot/templates/widgets/user_navigation.html @@ -3,15 +3,8 @@ <span class="user-info"> {{ macros.inbox_link(request.user) }} {{ macros.moderation_items_link(request.user, moderation_items) }} - {%- - if settings.KARMA_MODE != 'hidden' or settings.BADGES_MODE != 'hidden' - -%} - ({{ macros.user_long_score_and_badge_summary( - user, - karma_mode=settings.KARMA_MODE, - badges_mode=settings.BADGES_MODE - ) - }}) + {%- if settings.KARMA_MODE != 'hidden' or settings.BADGES_MODE != 'hidden' -%} + ({{ macros.user_long_score_and_badge_summary(user) }}) {%- endif -%} </span> {% if settings.USE_ASKBOT_LOGIN_SYSTEM %} |