4 commits - fedora_elections/__init__.py fedora_elections/mail_logging.py files/fedora-elections.spec
by Pierre-YvesChibon
fedora_elections/__init__.py | 20 +++++
fedora_elections/mail_logging.py | 148 +++++++++++++++++++++++++++++++++++++++
files/fedora-elections.spec | 7 +
3 files changed, 173 insertions(+), 2 deletions(-)
New commits:
commit 8b264751513fd490d2f3a4e8850734cd62beb512
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 25 16:17:21 2014 +0100
Release 2.4.2
diff --git a/fedora_elections/__init__.py b/fedora_elections/__init__.py
index 7ffd58a..8e301a9 100644
--- a/fedora_elections/__init__.py
+++ b/fedora_elections/__init__.py
@@ -24,7 +24,7 @@
# Pierre-Yves Chibon <pingou(a)fedoraproject.org>
#
-__version__ = '2.4.1'
+__version__ = '2.4.2'
import logging
import os
diff --git a/files/fedora-elections.spec b/files/fedora-elections.spec
index e159b06..4a12d5c 100644
--- a/files/fedora-elections.spec
+++ b/files/fedora-elections.spec
@@ -1,7 +1,7 @@
%define modname fedora_elections
Name: fedora-elections
-Version: 2.4.1
+Version: 2.4.2
Release: 1%{?dist}
Summary: Fedora elections application
@@ -111,6 +111,11 @@ install -m 644 files/update_1_to_2.sql \
%changelog
+* Tue Nov 25 2014 Pierre-Yves Chibon <pingou(a)pingoured.fr> - 2.4.2-1
+- Update to 2.4.2
+- Fix logging so that we log into apache's logs and email when having an
+ error
+
* Thu Nov 20 2014 Pierre-Yves Chibon <pingou(a)pingoured.fr> - 2.4.1-1
- Update to 2.4.1
- Adjust the election form to inform the user that cla_done is always required
commit 840d636b54e248a144b73c3a5eb6d35d09b88582
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 25 16:16:36 2014 +0100
Fix import and typo due to copy/paste
diff --git a/fedora_elections/__init__.py b/fedora_elections/__init__.py
index 74ca25e..7ffd58a 100644
--- a/fedora_elections/__init__.py
+++ b/fedora_elections/__init__.py
@@ -26,7 +26,9 @@
__version__ = '2.4.1'
+import logging
import os
+import sys
from datetime import datetime, time
from functools import wraps
@@ -41,6 +43,7 @@ from flask.ext.fas_openid import FAS
import dogpile.cache
import fedora_elections.fedmsgshim
+import fedora_elections.mail_logging
import fedora_elections.proxy
APP = flask.Flask(__name__)
@@ -53,7 +56,7 @@ FAS = FAS(APP)
# Set up the logging
if not APP.debug:
- APP.logger.addHandler(anitya.mail_logging.get_mail_handler(
+ APP.logger.addHandler(fedora_elections.mail_logging.get_mail_handler(
smtp_server=APP.config.get('SMTP_SERVER', '127.0.0.1'),
mail_admin=APP.config.get('MAIL_ADMIN', 'admin(a)fedoraproject.org')
))
commit e6f3c91b35d95aeb95b84a226ce903f9df9a7e36
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 25 16:06:53 2014 +0100
Set up logging properly to log to apache's logs and send email for errors
diff --git a/fedora_elections/__init__.py b/fedora_elections/__init__.py
index adff683..74ca25e 100644
--- a/fedora_elections/__init__.py
+++ b/fedora_elections/__init__.py
@@ -50,6 +50,21 @@ if 'FEDORA_ELECTIONS_CONFIG' in os.environ: # pragma: no cover
# set up FAS
FAS = FAS(APP)
+
+# Set up the logging
+if not APP.debug:
+ APP.logger.addHandler(anitya.mail_logging.get_mail_handler(
+ smtp_server=APP.config.get('SMTP_SERVER', '127.0.0.1'),
+ mail_admin=APP.config.get('MAIL_ADMIN', 'admin(a)fedoraproject.org')
+ ))
+
+# Log to stderr as well
+STDERR_LOG = logging.StreamHandler(sys.stderr)
+STDERR_LOG.setLevel(logging.INFO)
+APP.logger.addHandler(STDERR_LOG)
+
+LOG = APP.logger
+
APP.wsgi_app = fedora_elections.proxy.ReverseProxied(APP.wsgi_app)
# FAS for usernames.
commit 77d4b4e3814ca573731ca802049dce8aa07c54e0
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 25 16:06:32 2014 +0100
Add python module to set up the email handler for logs
diff --git a/fedora_elections/mail_logging.py b/fedora_elections/mail_logging.py
new file mode 100644
index 0000000..39562ad
--- /dev/null
+++ b/fedora_elections/mail_logging.py
@@ -0,0 +1,148 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2, or (at your option) any later
+# version. This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY expressed or implied, including the
+# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details. You
+# should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Any Red Hat trademarks that are incorporated in the source
+# code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission
+# of Red Hat, Inc.
+#
+
+'''
+Mail handler for logging.
+'''
+import logging
+import logging.handlers
+
+import inspect
+import os
+import socket
+import traceback
+
+psutil = None
+try:
+ import psutil
+except (OSError, ImportError):
+ # We run into issues when trying to import psutil from inside mod_wsgi on
+ # rhel7. If we hit that here, then just fail quietly.
+ # https://github.com/jmflinuxtx/kerneltest-harness/pull/17#issuecomment-480...
+ pass
+
+
+class ContextInjector(logging.Filter):
+ """ Logging filter that adds context to log records.
+
+ Filters are typically used to "filter" log records. They declare a filter
+ method that can return True or False. Only records with 'True' will
+ actually be logged.
+
+ Here, we somewhat abuse the concept of a filter. We always return true,
+ but we use the opportunity to hang important contextual information on the
+ log record to later be used by the logging Formatter. We don't normally
+ want to see all this stuff in normal log records, but we *do* want to see
+ it when we are emailed error messages. Seeing an error, but not knowing
+ which host it comes from, is not that useful.
+
+ http://docs.python.org/2/howto/logging-cookbook.html#filters-contextual
+
+ This code has been originally written by Ralph Bean for the fedmsg
+ project:
+ https://github.com/fedora-infra/fedmsg/
+ and can be found at:
+ https://infrastructure.fedoraproject.org/cgit/ansible.git/tree/roles/fedm...
+
+ """
+
+ def filter(self, record):
+ current_process = ContextInjector.get_current_process()
+ current_hostname = socket.gethostname()
+
+ record.host = current_hostname
+ record.proc = current_process
+ record.pid = '-'
+ if not isinstance(current_process, str):
+ record.pid = current_process.pid
+ record.proc_name = current_process.name
+ record.command_line = " ".join(current_process.cmdline)
+ record.callstack = self.format_callstack()
+ return True
+
+ @staticmethod
+ def format_callstack():
+ for i, frame in enumerate(f[0] for f in inspect.stack()):
+ if '__name__' not in frame.f_globals:
+ continue
+ modname = frame.f_globals['__name__'].split('.')[0]
+ if modname != "logging":
+ break
+
+ def _format_frame(frame):
+ return ' File "%s", line %i in %s\n %s' % (frame)
+
+ stack = traceback.extract_stack()
+ stack = stack[:-i]
+ return "\n".join([_format_frame(frame) for frame in stack])
+
+ @staticmethod
+ def get_current_process():
+ mypid = os.getpid()
+
+ if not psutil:
+ return "Could not import psutil for %r" % mypid
+
+ for proc in psutil.process_iter():
+ if proc.pid == mypid:
+ return proc
+
+ # This should be impossible.
+ raise ValueError("Could not find process %r" % mypid)
+
+
+MSG_FORMAT = """Process Details
+---------------
+host: %(host)s
+PID: %(pid)s
+name: %(proc_name)s
+command: %(command_line)s
+
+Message type: %(levelname)s
+Location: %(pathname)s:%(lineno)d
+Module: %(module)s
+Function: %(funcName)s
+Time: %(asctime)s
+
+Message:
+--------
+
+%(message)s
+
+
+Callstack that lead to the logging statement
+--------------------------------------------
+%(callstack)s
+"""
+
+
+def get_mail_handler(smtp_server, mail_admin):
+ """ Set up the handler sending emails for big exception
+ """
+ mail_handler = logging.handlers.SMTPHandler(
+ smtp_server,
+ 'nobody(a)fedoraproject.org',
+ mail_admin,
+ 'elections error')
+ mail_handler.setFormatter(logging.Formatter(MSG_FORMAT))
+ mail_handler.setLevel(logging.ERROR)
+ mail_handler.addFilter(ContextInjector())
+ return mail_handler
9 years, 5 months
Branch 'develop' - 3 commits - fedora_elections/__init__.py fedora_elections/mail_logging.py
by Pierre-YvesChibon
fedora_elections/__init__.py | 15 +++
fedora_elections/mail_logging.py | 148 +++++++++++++++++++++++++++++++++++++++
2 files changed, 163 insertions(+)
New commits:
commit a3da86e46e87502a73823b115f48b035c23fc829
Merge: cafb4b2 e6f3c91
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 25 16:13:42 2014 +0100
Merge pull request #39 from fedora-infra/fix_logging
Fix logging
commit e6f3c91b35d95aeb95b84a226ce903f9df9a7e36
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 25 16:06:53 2014 +0100
Set up logging properly to log to apache's logs and send email for errors
diff --git a/fedora_elections/__init__.py b/fedora_elections/__init__.py
index adff683..74ca25e 100644
--- a/fedora_elections/__init__.py
+++ b/fedora_elections/__init__.py
@@ -50,6 +50,21 @@ if 'FEDORA_ELECTIONS_CONFIG' in os.environ: # pragma: no cover
# set up FAS
FAS = FAS(APP)
+
+# Set up the logging
+if not APP.debug:
+ APP.logger.addHandler(anitya.mail_logging.get_mail_handler(
+ smtp_server=APP.config.get('SMTP_SERVER', '127.0.0.1'),
+ mail_admin=APP.config.get('MAIL_ADMIN', 'admin(a)fedoraproject.org')
+ ))
+
+# Log to stderr as well
+STDERR_LOG = logging.StreamHandler(sys.stderr)
+STDERR_LOG.setLevel(logging.INFO)
+APP.logger.addHandler(STDERR_LOG)
+
+LOG = APP.logger
+
APP.wsgi_app = fedora_elections.proxy.ReverseProxied(APP.wsgi_app)
# FAS for usernames.
commit 77d4b4e3814ca573731ca802049dce8aa07c54e0
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Nov 25 16:06:32 2014 +0100
Add python module to set up the email handler for logs
diff --git a/fedora_elections/mail_logging.py b/fedora_elections/mail_logging.py
new file mode 100644
index 0000000..39562ad
--- /dev/null
+++ b/fedora_elections/mail_logging.py
@@ -0,0 +1,148 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2, or (at your option) any later
+# version. This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY expressed or implied, including the
+# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details. You
+# should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Any Red Hat trademarks that are incorporated in the source
+# code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission
+# of Red Hat, Inc.
+#
+
+'''
+Mail handler for logging.
+'''
+import logging
+import logging.handlers
+
+import inspect
+import os
+import socket
+import traceback
+
+psutil = None
+try:
+ import psutil
+except (OSError, ImportError):
+ # We run into issues when trying to import psutil from inside mod_wsgi on
+ # rhel7. If we hit that here, then just fail quietly.
+ # https://github.com/jmflinuxtx/kerneltest-harness/pull/17#issuecomment-480...
+ pass
+
+
+class ContextInjector(logging.Filter):
+ """ Logging filter that adds context to log records.
+
+ Filters are typically used to "filter" log records. They declare a filter
+ method that can return True or False. Only records with 'True' will
+ actually be logged.
+
+ Here, we somewhat abuse the concept of a filter. We always return true,
+ but we use the opportunity to hang important contextual information on the
+ log record to later be used by the logging Formatter. We don't normally
+ want to see all this stuff in normal log records, but we *do* want to see
+ it when we are emailed error messages. Seeing an error, but not knowing
+ which host it comes from, is not that useful.
+
+ http://docs.python.org/2/howto/logging-cookbook.html#filters-contextual
+
+ This code has been originally written by Ralph Bean for the fedmsg
+ project:
+ https://github.com/fedora-infra/fedmsg/
+ and can be found at:
+ https://infrastructure.fedoraproject.org/cgit/ansible.git/tree/roles/fedm...
+
+ """
+
+ def filter(self, record):
+ current_process = ContextInjector.get_current_process()
+ current_hostname = socket.gethostname()
+
+ record.host = current_hostname
+ record.proc = current_process
+ record.pid = '-'
+ if not isinstance(current_process, str):
+ record.pid = current_process.pid
+ record.proc_name = current_process.name
+ record.command_line = " ".join(current_process.cmdline)
+ record.callstack = self.format_callstack()
+ return True
+
+ @staticmethod
+ def format_callstack():
+ for i, frame in enumerate(f[0] for f in inspect.stack()):
+ if '__name__' not in frame.f_globals:
+ continue
+ modname = frame.f_globals['__name__'].split('.')[0]
+ if modname != "logging":
+ break
+
+ def _format_frame(frame):
+ return ' File "%s", line %i in %s\n %s' % (frame)
+
+ stack = traceback.extract_stack()
+ stack = stack[:-i]
+ return "\n".join([_format_frame(frame) for frame in stack])
+
+ @staticmethod
+ def get_current_process():
+ mypid = os.getpid()
+
+ if not psutil:
+ return "Could not import psutil for %r" % mypid
+
+ for proc in psutil.process_iter():
+ if proc.pid == mypid:
+ return proc
+
+ # This should be impossible.
+ raise ValueError("Could not find process %r" % mypid)
+
+
+MSG_FORMAT = """Process Details
+---------------
+host: %(host)s
+PID: %(pid)s
+name: %(proc_name)s
+command: %(command_line)s
+
+Message type: %(levelname)s
+Location: %(pathname)s:%(lineno)d
+Module: %(module)s
+Function: %(funcName)s
+Time: %(asctime)s
+
+Message:
+--------
+
+%(message)s
+
+
+Callstack that lead to the logging statement
+--------------------------------------------
+%(callstack)s
+"""
+
+
+def get_mail_handler(smtp_server, mail_admin):
+ """ Set up the handler sending emails for big exception
+ """
+ mail_handler = logging.handlers.SMTPHandler(
+ smtp_server,
+ 'nobody(a)fedoraproject.org',
+ mail_admin,
+ 'elections error')
+ mail_handler.setFormatter(logging.Formatter(MSG_FORMAT))
+ mail_handler.setLevel(logging.ERROR)
+ mail_handler.addFilter(ContextInjector())
+ return mail_handler
9 years, 5 months
Branch 'develop' - fedora_elections/__init__.py files/fedora-elections.spec
by Pierre-YvesChibon
fedora_elections/__init__.py | 2 +-
files/fedora-elections.spec | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
New commits:
commit cafb4b2d332fb37e5d0c603f6ecbe75967c38f6c
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 16:16:03 2014 +0100
Release 2.4.1
diff --git a/fedora_elections/__init__.py b/fedora_elections/__init__.py
index 9b15597..adff683 100644
--- a/fedora_elections/__init__.py
+++ b/fedora_elections/__init__.py
@@ -24,7 +24,7 @@
# Pierre-Yves Chibon <pingou(a)fedoraproject.org>
#
-__version__ = '2.4'
+__version__ = '2.4.1'
import os
diff --git a/files/fedora-elections.spec b/files/fedora-elections.spec
index c8ab8ce..e159b06 100644
--- a/files/fedora-elections.spec
+++ b/files/fedora-elections.spec
@@ -1,7 +1,7 @@
%define modname fedora_elections
Name: fedora-elections
-Version: 2.4
+Version: 2.4.1
Release: 1%{?dist}
Summary: Fedora elections application
@@ -111,6 +111,15 @@ install -m 644 files/update_1_to_2.sql \
%changelog
+* Thu Nov 20 2014 Pierre-Yves Chibon <pingou(a)pingoured.fr> - 2.4.1-1
+- Update to 2.4.1
+- Adjust the election form to inform the user that cla_done is always required
+ to vote (Patrick Uiterwijk)
+- Fix the display of the name retrieved from FAS in the result page
+- Make the about page rely on the cached information
+- Add blinker to the list of deps in the requirements.txt for the unit-tests
+ to pass on jenkins
+
* Thu Nov 20 2014 Pierre-Yves Chibon <pingou(a)pingoured.fr> - 2.4-1
- Update to 2.4
- Fix the election creation/edit page to show all the labels
@@ -120,7 +129,7 @@ install -m 644 files/update_1_to_2.sql \
email with the results
- Add new election type: IRC allowing users to do +1/0/-1 votes
- Add session time-out
-- Add caching for the information retrieved from FAS
+- Add caching for the information retrieved from FAS (Ralph Bean)
- Add python-dogpile-cache as BR and R
* Wed Jul 16 2014 Pierre-Yves Chibon <pingou(a)pingoured.fr> - 2.3-1
9 years, 6 months
Changes to 'refs/tags/v2.4.1'
by Pierre-YvesChibon
Tag 'v2.4.1' created by Pierre-Yves Chibon <pingou(a)pingoured.fr> at 2014-11-20 15:23 +0000
Release 2.4.1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iEYEABECAAYFAlRuB4IACgkQ2HRbBxDocwr+7gCfRJ/TX3xipKzWkvMIYBn66PUA
PpgAn3LfvGwrVtl6DQ5Bd+KLEWvwPqJ5
=iPRg
-----END PGP SIGNATURE-----
Changes since v2.4:
Patrick Uiterwijk (1):
Explain the CLA-done is always required
Pierre-Yves Chibon (6):
Fix displaying the real name retrieved from FAS present inthe usernamemap
Let the about page of an election use the cached information
Merge pull request #37 from fedora-infra/fix-cla-done-ui
Add blinker to the list of dependencies as it's required for the unit-tests
Merge pull request #38 from fedora-infra/fix_caching
Release 2.4.1
---
fedora_elections/__init__.py | 13 +++----------
fedora_elections/templates/about.html | 2 +-
fedora_elections/templates/admin/election_form.html | 2 +-
fedora_elections/templates/results.html | 2 +-
files/fedora-elections.spec | 13 +++++++++++--
requirements.txt | 1 +
6 files changed, 18 insertions(+), 15 deletions(-)
---
9 years, 6 months
7 commits - fedora_elections/__init__.py fedora_elections/templates files/fedora-elections.spec requirements.txt
by Pierre-YvesChibon
fedora_elections/__init__.py | 13 +++----------
fedora_elections/templates/about.html | 2 +-
fedora_elections/templates/admin/election_form.html | 2 +-
fedora_elections/templates/results.html | 2 +-
files/fedora-elections.spec | 13 +++++++++++--
requirements.txt | 1 +
6 files changed, 18 insertions(+), 15 deletions(-)
New commits:
commit cafb4b2d332fb37e5d0c603f6ecbe75967c38f6c
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 16:16:03 2014 +0100
Release 2.4.1
diff --git a/fedora_elections/__init__.py b/fedora_elections/__init__.py
index 9b15597..adff683 100644
--- a/fedora_elections/__init__.py
+++ b/fedora_elections/__init__.py
@@ -24,7 +24,7 @@
# Pierre-Yves Chibon <pingou(a)fedoraproject.org>
#
-__version__ = '2.4'
+__version__ = '2.4.1'
import os
diff --git a/files/fedora-elections.spec b/files/fedora-elections.spec
index c8ab8ce..e159b06 100644
--- a/files/fedora-elections.spec
+++ b/files/fedora-elections.spec
@@ -1,7 +1,7 @@
%define modname fedora_elections
Name: fedora-elections
-Version: 2.4
+Version: 2.4.1
Release: 1%{?dist}
Summary: Fedora elections application
@@ -111,6 +111,15 @@ install -m 644 files/update_1_to_2.sql \
%changelog
+* Thu Nov 20 2014 Pierre-Yves Chibon <pingou(a)pingoured.fr> - 2.4.1-1
+- Update to 2.4.1
+- Adjust the election form to inform the user that cla_done is always required
+ to vote (Patrick Uiterwijk)
+- Fix the display of the name retrieved from FAS in the result page
+- Make the about page rely on the cached information
+- Add blinker to the list of deps in the requirements.txt for the unit-tests
+ to pass on jenkins
+
* Thu Nov 20 2014 Pierre-Yves Chibon <pingou(a)pingoured.fr> - 2.4-1
- Update to 2.4
- Fix the election creation/edit page to show all the labels
@@ -120,7 +129,7 @@ install -m 644 files/update_1_to_2.sql \
email with the results
- Add new election type: IRC allowing users to do +1/0/-1 votes
- Add session time-out
-- Add caching for the information retrieved from FAS
+- Add caching for the information retrieved from FAS (Ralph Bean)
- Add python-dogpile-cache as BR and R
* Wed Jul 16 2014 Pierre-Yves Chibon <pingou(a)pingoured.fr> - 2.3-1
commit 8a2fd24986c314ec5f08b1d1d30169e44ae2a10c
Merge: 043232e 1c5d618
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 16:08:12 2014 +0100
Merge pull request #38 from fedora-infra/fix_caching
Fix caching
commit 043232e4cfe4a5cce8aeb46cc5e9be7dd9e6d1da
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 13:41:11 2014 +0100
Add blinker to the list of dependencies as it's required for the unit-tests
diff --git a/requirements.txt b/requirements.txt
index a62a392..4810410 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -10,3 +10,4 @@ python-openid-teams
SQLAlchemy
wtforms
dogpile.cache
+blinker # required by Flask for the unit-tests (for signaling)
commit 8aa198f9cfc1e72fa15b6ed1bba168e1308244e4
Merge: cd97446 1148bd3
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 13:39:57 2014 +0100
Merge pull request #37 from fedora-infra/fix-cla-done-ui
Explain the CLA-done is always required
commit 1c5d618971da5e617cb9224f8546cbb8329fc3bc
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 13:11:21 2014 +0100
Let the about page of an election use the cached information
diff --git a/fedora_elections/__init__.py b/fedora_elections/__init__.py
index 157a435..9b15597 100644
--- a/fedora_elections/__init__.py
+++ b/fedora_elections/__init__.py
@@ -68,6 +68,7 @@ from fedora_elections import forms
cache = dogpile.cache.make_region()
cache.configure(**APP.config['DOGPILE_CACHE'])
+from fedora_elections.utils import build_name_map
def is_authenticated():
@@ -208,15 +209,7 @@ def about_election(election_alias):
flask.flash('The election, %s, does not exist.' % election_alias)
return safe_redirect_back()
- usernamemap = {}
- if (election.candidates_are_fasusers): # pragma: no cover
- for candidate in election.candidates:
- try:
- usernamemap[candidate.id] = \
- FAS2.person_by_username(candidate.name)['human_name']
- except (KeyError, AuthError):
- # User has their name set to private or user doesn't exist.
- usernamemap[candidate.id] = candidate.name
+ usernamemap = build_name_map(election)
return flask.render_template(
'about.html',
diff --git a/fedora_elections/templates/about.html b/fedora_elections/templates/about.html
index e2008ff..aaca52a 100644
--- a/fedora_elections/templates/about.html
+++ b/fedora_elections/templates/about.html
@@ -15,7 +15,7 @@
<tr>
<td>
{% if election.candidates_are_fasusers %}
- {{ usernamemap[candidate.id] }}
+ {{ usernamemap['%s' % candidate.id] }}
{% else %}
{{ candidate.name }}
{% endif %}
commit 888bbdf728ce454a2399a4cbe59a5a8d3ffd617a
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 13:10:54 2014 +0100
Fix displaying the real name retrieved from FAS present inthe usernamemap
diff --git a/fedora_elections/templates/results.html b/fedora_elections/templates/results.html
index 435073b..f8cc334 100644
--- a/fedora_elections/templates/results.html
+++ b/fedora_elections/templates/results.html
@@ -38,7 +38,7 @@
<tr class="{% if lastrow == True %}firstout{% endif %} {{ loop.cycle('row_odd', 'row_even') }}">
<td>
{% if election.candidates_are_fasusers %}
- {{ usernamemap[candidate.id] }}
+ {{ usernamemap['%s' % candidate.id] }}
{% else %}
{{candidate.name}}
{% endif %}
commit 1148bd3d2b6229a241901d8ddff55162e0d31d45
Author: Patrick Uiterwijk <puiterwijk(a)redhat.com>
Date: Tue Nov 18 13:57:44 2014 +0100
Explain the CLA-done is always required
diff --git a/fedora_elections/templates/admin/election_form.html b/fedora_elections/templates/admin/election_form.html
index a3dcde8..eea64b3 100644
--- a/fedora_elections/templates/admin/election_form.html
+++ b/fedora_elections/templates/admin/election_form.html
@@ -22,7 +22,7 @@
{{ render_field_in_row(form.seats_elected) }}
{{ render_field_in_row(form.candidates_are_fasusers) }}
{{ render_field_in_row(form.embargoed) }}
- {{ render_field_in_row(form.lgl_voters, after="FAS groups allowed to vote on this election") }}
+ {{ render_field_in_row(form.lgl_voters, after="FAS groups allowed to vote on this election (CLA-done is always required)") }}
{{ render_field_in_row(form.admin_grp, after="FAS groups allowed to view the result despite the embargo") }}
</table>
</fieldset>
9 years, 6 months
Branch 'develop' - 3 commits - fedora_elections/__init__.py fedora_elections/templates
by Pierre-YvesChibon
fedora_elections/__init__.py | 11 ++---------
fedora_elections/templates/about.html | 2 +-
fedora_elections/templates/results.html | 2 +-
3 files changed, 4 insertions(+), 11 deletions(-)
New commits:
commit 8a2fd24986c314ec5f08b1d1d30169e44ae2a10c
Merge: 043232e 1c5d618
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 16:08:12 2014 +0100
Merge pull request #38 from fedora-infra/fix_caching
Fix caching
commit 1c5d618971da5e617cb9224f8546cbb8329fc3bc
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 13:11:21 2014 +0100
Let the about page of an election use the cached information
diff --git a/fedora_elections/__init__.py b/fedora_elections/__init__.py
index 157a435..9b15597 100644
--- a/fedora_elections/__init__.py
+++ b/fedora_elections/__init__.py
@@ -68,6 +68,7 @@ from fedora_elections import forms
cache = dogpile.cache.make_region()
cache.configure(**APP.config['DOGPILE_CACHE'])
+from fedora_elections.utils import build_name_map
def is_authenticated():
@@ -208,15 +209,7 @@ def about_election(election_alias):
flask.flash('The election, %s, does not exist.' % election_alias)
return safe_redirect_back()
- usernamemap = {}
- if (election.candidates_are_fasusers): # pragma: no cover
- for candidate in election.candidates:
- try:
- usernamemap[candidate.id] = \
- FAS2.person_by_username(candidate.name)['human_name']
- except (KeyError, AuthError):
- # User has their name set to private or user doesn't exist.
- usernamemap[candidate.id] = candidate.name
+ usernamemap = build_name_map(election)
return flask.render_template(
'about.html',
diff --git a/fedora_elections/templates/about.html b/fedora_elections/templates/about.html
index e2008ff..aaca52a 100644
--- a/fedora_elections/templates/about.html
+++ b/fedora_elections/templates/about.html
@@ -15,7 +15,7 @@
<tr>
<td>
{% if election.candidates_are_fasusers %}
- {{ usernamemap[candidate.id] }}
+ {{ usernamemap['%s' % candidate.id] }}
{% else %}
{{ candidate.name }}
{% endif %}
commit 888bbdf728ce454a2399a4cbe59a5a8d3ffd617a
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 13:10:54 2014 +0100
Fix displaying the real name retrieved from FAS present inthe usernamemap
diff --git a/fedora_elections/templates/results.html b/fedora_elections/templates/results.html
index 435073b..f8cc334 100644
--- a/fedora_elections/templates/results.html
+++ b/fedora_elections/templates/results.html
@@ -38,7 +38,7 @@
<tr class="{% if lastrow == True %}firstout{% endif %} {{ loop.cycle('row_odd', 'row_even') }}">
<td>
{% if election.candidates_are_fasusers %}
- {{ usernamemap[candidate.id] }}
+ {{ usernamemap['%s' % candidate.id] }}
{% else %}
{{candidate.name}}
{% endif %}
9 years, 6 months
Branch 'develop' - 3 commits - fedora_elections/templates requirements.txt
by Pierre-YvesChibon
fedora_elections/templates/admin/election_form.html | 2 +-
requirements.txt | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 043232e4cfe4a5cce8aeb46cc5e9be7dd9e6d1da
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 13:41:11 2014 +0100
Add blinker to the list of dependencies as it's required for the unit-tests
diff --git a/requirements.txt b/requirements.txt
index a62a392..4810410 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -10,3 +10,4 @@ python-openid-teams
SQLAlchemy
wtforms
dogpile.cache
+blinker # required by Flask for the unit-tests (for signaling)
commit 8aa198f9cfc1e72fa15b6ed1bba168e1308244e4
Merge: cd97446 1148bd3
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Nov 20 13:39:57 2014 +0100
Merge pull request #37 from fedora-infra/fix-cla-done-ui
Explain the CLA-done is always required
commit 1148bd3d2b6229a241901d8ddff55162e0d31d45
Author: Patrick Uiterwijk <puiterwijk(a)redhat.com>
Date: Tue Nov 18 13:57:44 2014 +0100
Explain the CLA-done is always required
diff --git a/fedora_elections/templates/admin/election_form.html b/fedora_elections/templates/admin/election_form.html
index a3dcde8..eea64b3 100644
--- a/fedora_elections/templates/admin/election_form.html
+++ b/fedora_elections/templates/admin/election_form.html
@@ -22,7 +22,7 @@
{{ render_field_in_row(form.seats_elected) }}
{{ render_field_in_row(form.candidates_are_fasusers) }}
{{ render_field_in_row(form.embargoed) }}
- {{ render_field_in_row(form.lgl_voters, after="FAS groups allowed to vote on this election") }}
+ {{ render_field_in_row(form.lgl_voters, after="FAS groups allowed to vote on this election (CLA-done is always required)") }}
{{ render_field_in_row(form.admin_grp, after="FAS groups allowed to view the result despite the embargo") }}
</table>
</fieldset>
9 years, 6 months
[Fedora Elections] #42: Different end date time when creating/editing elections
by fedora-badges
#42: Different end date time when creating/editing elections
----------------------------+-----------------------------
Reporter: jreznik | Owner: nigelj
Type: defect | Status: new
Priority: major | Milestone: Future Release
Component: Administration | Version:
Keywords: | Blocked By:
Blocking: |
----------------------------+-----------------------------
Create elections, save and observe date/time for end date.
Start date: 2014-11-19 00:00:00[[BR]]
End date: 2014-11-21 '''23:59:59'''
Then click Edit election, no need to change anything and click Save
Changes and you'll get different end date time.
Start date: 2014-11-19 00:00:00[[BR]]
End date: 2014-11-21 '''00:00:00'''
What's the correct date? After the latest change to 00:00:00 for
everything, I expect the second one is correct. There are Council
elections going on, would be nice to check it before the end.
Test elections URL: https://admin.stg.fedoraproject.org/voting/admin
/alias-test-ele/
Version: 2.3
--
Ticket URL: <https://fedorahosted.org/elections/ticket/42>
Fedora Elections <https://fedorahosted.org/elections/>
Fedora Elections
9 years, 6 months