From da0fcb833c119fa5b4ab42f113906a15ce4c55a3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 06 2016 09:47:24 +0000 Subject: [PATCH 1/5] Add a welcome screen to new users of pagure Fixes https://pagure.io/pagure/issue/1234 --- diff --git a/pagure/__init__.py b/pagure/__init__.py index 66274b6..591d27e 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -96,6 +96,11 @@ if APP.config.get('PAGURE_AUTH', None) in ['fas', 'openid']: @FAS.postlogin def set_user(return_url): ''' After login method. ''' + flask.session['_new_user'] = False + if not pagure.lib.search_user( + SESSION, username=flask.g.fas_user.username): + flask.session['_new_user'] = True + try: pagure.lib.set_up_user( session=SESSION, @@ -353,12 +358,19 @@ def inject_variables(): namespace=namespace) return watch + new_user = False + if flask.session.get('_new_user'): + new_user = True + flask.flash('Welcome to pagure') + flask.session['_new_user'] = False + return dict( version=__version__, admin=user_admin, authenticated=authenticated(), forkbuttonform=forkbuttonform, is_watching=is_watching, + new_user=new_user, ) diff --git a/pagure/templates/master.html b/pagure/templates/master.html index e622b64..7d71fcc 100644 --- a/pagure/templates/master.html +++ b/pagure/templates/master.html @@ -127,6 +127,42 @@ + {% if new_user %} + + {% endif %} + {% block jscripts %} + {% if new_user %} + + {% endif %} {% endblock %} {% if config['FEDMENU_URL'] %} From c2a3631f7031be8a06566a4b870ba69a8a65354c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 06 2016 09:47:24 +0000 Subject: [PATCH 2/5] Small grammar improvements suggested by @tibbs, thanks! --- diff --git a/pagure/templates/master.html b/pagure/templates/master.html index 7d71fcc..c00cfc8 100644 --- a/pagure/templates/master.html +++ b/pagure/templates/master.html @@ -137,16 +137,18 @@ aria-label="Close"> - + {% endif %} {% endwith %} + {% if new_user %} +
+
+ +
+
+ {% endif %} {% block content %}{% endblock %} @@ -127,44 +157,6 @@ - {% if new_user %} - - {% endif %} - {% block jscripts %} - {% if new_user %} - - {% endif %} {% endblock %} {% if config['FEDMENU_URL'] %} From 2eacfa5a833f9fcf963b778d35a313a5145c555d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 06 2016 09:47:24 +0000 Subject: [PATCH 4/5] Drop this flash message, duplicates the welcome screen --- diff --git a/pagure/__init__.py b/pagure/__init__.py index 591d27e..45fed05 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -361,7 +361,6 @@ def inject_variables(): new_user = False if flask.session.get('_new_user'): new_user = True - flask.flash('Welcome to pagure') flask.session['_new_user'] = False return dict( From bc0554cb86f9b08ca7adc062ae3a955a346adedd Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 06 2016 09:57:47 +0000 Subject: [PATCH 5/5] Make the instance name configurable and reword a little the welcome screen --- diff --git a/doc/configuration.rst b/doc/configuration.rst index 0fdffef..f3e0e3b 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -530,3 +530,15 @@ the only CI service supported at the moment). Defaults to: ``None``. .. warning:: Requires `Redis` to be configured and running. + + +INSTANCE_NAME +~~~~~~~~~~~~~ + +This allows giving a name to this running instance of pagure. The name is +then used in the welcome screen showns upon first login. + +Defaults to: ``Pagure`` + +.. note: the welcome screen currently does not work with the `local` + authentication. diff --git a/pagure/default_config.py b/pagure/default_config.py index 932d4d5..6b03967 100644 --- a/pagure/default_config.py +++ b/pagure/default_config.py @@ -21,6 +21,10 @@ SECRET_KEY = '' # url to the database server: DB_URL = 'sqlite:////var/tmp/pagure_dev.sqlite' +# Name the instance, used in the welcome screen upon first login (not +# working with `local` auth) +INSTANCE_NAME = 'Pagure' + # url to datagrepper (optional): #DATAGREPPER_URL = 'https://apps.fedoraproject.org/datagrepper' #DATAGREPPER_CATEGORY = 'pagure' diff --git a/pagure/templates/master.html b/pagure/templates/master.html index e227a20..d20f9be 100644 --- a/pagure/templates/master.html +++ b/pagure/templates/master.html @@ -116,20 +116,23 @@