Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Cleanhistory #133

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
sudo: false
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"

install:
- pip install tox-travis
Expand Down
35 changes: 26 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
nuancier
========

.. image:: http://shieldkins.elrod.me/fedora/nuancier

:Author: Pierre-Yves Chibon <[email protected]>


Expand Down Expand Up @@ -39,7 +37,7 @@ order to increase the loading speed of the pages.

The dependency list is therefore:

- `python`_ (2.5 minimum)
- `python`_ (3.7 minimum)
- `python-flask`_
- `python-flask-wtf`_
- `python-wtforms`_
Expand All @@ -61,7 +59,7 @@ The best way to set up a development enviroment is to use `Vagrant <https://vagr
Vagrant provisions a new virtual machine and then runs the Ansible playbook on it automatically.
To get started, install Vagrant::

$ sudo dnf install vagrant libvirt vagrant-libvirt vagrant-sshfs ansible
$ sudo dnf install vagrant libvirt vagrant-libvirt vagrant-sshfs ansible git

Next, clone the repository and copy the example Vagrantfile from ``Vagrantfile.example``::

Expand All @@ -78,22 +76,41 @@ All done! The VM contains all the required dependencies pre-installed.
Manual
^^^^^^

Instructions here have been tested on Fedora 30, using Python3

Get git and python3:

sudo dnf install git python3

Clone the source::

git clone https://github.com/fedora-infra/nuancier.git
git clone https://github.com/fedora-infra/nuancier.git

Install Python requirements

pip3 install -r requirements.txt

Create the database scheme::

python createdb.py

python3 createdb.py

Run the server::
Run the server locally::

python runserver.py
python3 runserver.py

You should be able to access the server at http://localhost:5000

or to run the server externally, first open relevant port in firewall::

sudo firewall-cmd --add-port 5000/tcp --permanent
sudo firewall-cmd --reload

then run the server::

python3 runserver.py --host 0.0.0.0

You should be able to access the server at http://ip.address:5000

.. note:: To tweak the configuration, you may either change
``default_config.py`` in the nuancier module, or copy the file
``utility/nuancier.cfg.sample`` into ``nuancier.cfg`` and run the
Expand Down
12 changes: 6 additions & 6 deletions Vagrantfile.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# If you'd prefer to pull your boxes from Hashicorp's repository, you can
# replace the config.vm.box and config.vm.box_url declarations with the line below.
#
# config.vm.box = "fedora/25-cloud-base"
config.vm.box = "f25-cloud-libvirt"
# config.vm.box = "fedora/32-cloud-base"
config.vm.box = "f32-cloud-libvirt"
config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases"\
"/25/CloudImages/x86_64/images/Fedora-Cloud-Base-Vagrant-25-1"\
".3.x86_64.vagrant-libvirt.box"
"/32/Cloud/x86_64/images/Fedora-Cloud-Base-Vagrant-32-1"\
".6.x86_64.vagrant-libvirt.box"

# Forward traffic on the host to the development server on the guest.
# You can change the host port that is forwarded to 5000 on the guest
Expand All @@ -31,7 +31,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Vagrant can share the source directory using rsync, NFS, or SSHFS (with the vagrant-sshfs
# plugin). Consult the Vagrant documentation if you do not want to use SSHFS.
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/home/vagrant/devel", type: "sshfs", sshfs_opts_append: "-o nonempty"
config.vm.synced_folder ".", "/home/vagrant/devel", type: "sshfs"

# To cache update packages (which is helpful if frequently doing `vagrant destroy && vagrant up`)
# you can create a local directory and share it to the guest's DNF cache. Uncomment the lines below
Expand All @@ -44,7 +44,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", inline: "sudo dnf upgrade -y"

# bootstrap and run with ansible
config.vm.provision "shell", inline: "sudo dnf -y install python2-dnf libselinux-python"
config.vm.provision "shell", inline: "sudo dnf -y install python3-dnf python3-libselinux"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "devel/ansible/vagrant-playbook.yml"
end
Expand Down
2 changes: 1 addition & 1 deletion alembic/versions/7db0e24a2a85_add_submission_end_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def upgrade():
"submission_date_end=election_date_start;"
op.execute(ins)
except Exception as err:
print 'ERROR', err
print('ERROR', err)

## Enforce the nullable=False
op.alter_column(
Expand Down
25 changes: 14 additions & 11 deletions devel/ansible/roles/nuancier-dev/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
---

- name: Install helpful development packages
dnf: name={{ item }} state=present
with_items:
dnf:
name: "{{ item }}"
state: present
loop:
- git
- python-sphinx
- python-virtualenvwrapper
- python3-sphinx
- python3-virtualenvwrapper
- vim-enhanced

- name: Install nuancier system dependencies
dnf: name={{ item }} state=present
with_items:
dnf:
name: "{{ item }}"
state: present
loop:
- gcc
- libffi-devel
- openssl-devel
- python2-devel
- python3-devel
- redhat-rpm-config
- rpm-python
- python3-rpm

# Add various helpful configuration files
- name: Install a custom bashrc
Expand Down Expand Up @@ -49,7 +52,7 @@
pip:
requirements: "requirements.txt"
virtualenv: /home/{{ ansible_env.SUDO_USER }}/.virtualenvs/nuancier/
virtualenv_python: python2
virtualenv_python: python3
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel

Expand All @@ -58,7 +61,7 @@
pip:
requirements: "test-requirements.txt"
virtualenv: /home/{{ ansible_env.SUDO_USER }}/.virtualenvs/nuancier/
virtualenv_python: python2
virtualenv_python: python3
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel

Expand All @@ -68,7 +71,7 @@
name: "file:///home/{{ ansible_env.SUDO_USER }}/devel"
extra_args: "-e"
virtualenv: /home/{{ ansible_env.SUDO_USER }}/.virtualenvs/nuancier/
virtualenv_python: python2
virtualenv_python: python3


# Create and configure the database
Expand Down
4 changes: 2 additions & 2 deletions doc/deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ From system-wide packages

Start by install nuancier::

yum install nuancier
dnf install nuancier

Adjust the configuration files: ``/etc/nuancier/nuancier.cfg``.
See :doc:`configuration` for detailed information about the configuration.
Expand All @@ -48,7 +48,7 @@ Set-up WSGI

Start by installing ``mod_wsgi``::

yum install mod_wsgi
dnf install mod_wsgi


Then configure apache::
Expand Down
4 changes: 2 additions & 2 deletions doc/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ We are also inspecting the code using `pylint

::

yum install python-pep8 pylint
dnf install python-pep8 pylint


Send patch
Expand Down Expand Up @@ -147,7 +147,7 @@ error or failure. For example, the command could be:

::

yum install python-coverage
dnf install python-coverage


Database changes
Expand Down
2 changes: 1 addition & 1 deletion nuancier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from flask_fas_openid import FAS
from six.moves.urllib.parse import urlparse, urljoin
from sqlalchemy.exc import SQLAlchemyError
from werkzeug import secure_filename
from werkzeug.utils import secure_filename

try:
from PIL import Image
Expand Down
6 changes: 6 additions & 0 deletions nuancier/templates/admin_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,35 @@ <h3>Admin interface</h3>
<td>
{% if election.submission_open %}
<img src="{{ url_for('static', filename='Approved.png') }}"
title="Submission open"
alt="Submission open"/>
{% else %}
<img src="{{ url_for('static', filename='Denied.png') }}"
title="Submission closed"
alt="Submission closed"/>
{% endif %}
{{ election.submission_date_start }}
</td>
<td>
{% if election.election_open %}
<img src="{{ url_for('static', filename='Approved.png') }}"
title="Election open"
alt="Election open"/>
{% else %}
<img src="{{ url_for('static', filename='Denied.png') }}"
title="Election closed"
alt="Election closed"/>
{% endif %}
{{ election.election_date_start }}
</td>
<td>
{% if election.election_public %}
<img src="{{ url_for('static', filename='Approved.png') }}"
title="Election's results published"
alt="Election's results published"/>
{% else %}
<img src="{{ url_for('static', filename='Denied.png') }}"
title="Election's results closed"
alt="Election's results closed"/>
{% endif %}
{{ election.election_date_end }}
Expand Down
5 changes: 4 additions & 1 deletion nuancier/templates/admin_review.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>Review election: {{ election.election_name }} - {{ election.election_year }}

<h3>Overview</h3>
<p>Here below are presented all the candidates of the election {{ election.election_name }}
from {{ election.election_year }}, regardless of wether they are valid
from {{ election.election_year }}, regardless of whether they are valid
candidates or not.
</p>
<p>
Expand Down Expand Up @@ -111,12 +111,15 @@ <h3>Overview</h3>
<td>
{% if candidate.approved == true%}
<img src="{{ url_for('static', filename='Approved.png') }}"
title="Candidate approved"
alt="Candidate approved"/>
{% elif candidate.denied == true %}
<img src="{{ url_for('static', filename='Denied.png') }}"
title="Candidate denied"
alt="Candidate denied"/>
{% else %}
<img src="{{ url_for('static', filename='New.png') }}"
title="Candidate Pending Review"
alt="Candidate Pending Review"/>
{% endif %}
</td>
Expand Down
5 changes: 4 additions & 1 deletion nuancier/templates/admin_review_ro.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>Review election: {{ election.election_name }} - {{ election.election_year }}

<h3>Overview</h3>
<p>Here below are presented all the candidates of the election {{ election.election_name }}
from {{ election.election_year }}, regardless of wether they are valid
from {{ election.election_year }}, regardless of whether they are valid
candidates or not.
</p>
<p>
Expand Down Expand Up @@ -97,12 +97,15 @@ <h3>Overview</h3>
<td>
{% if candidate.approved == true%}
<img src="{{ url_for('static', filename='Approved.png') }}"
title="Candidate approved"
alt="Candidate approved"/>
{% elif candidate.denied == true %}
<img src="{{ url_for('static', filename='Denied.png') }}"
title="Candidate denied"
alt="Candidate denied"/>
{% else %}
<img src="{{ url_for('static', filename='New.png') }}"
title="Candidate Pending Review"
alt="Candidate Pending Review"/>
{% endif %}
</td>
Expand Down
3 changes: 3 additions & 0 deletions nuancier/templates/contributions.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ <h3>Overview</h3>
<td>
{% if candidate.approved == true %}
<img src="{{ url_for('static', filename='Approved.png') }}"
title="Candidate approved"
alt="Candidate approved"/>
{% elif candidate.denied == true %}
<img src="{{ url_for('static', filename='Denied.png') }}"
title="Candidate denied"
alt="Candidate denied"/>
{% else %}
<img src="{{ url_for('static', filename='New.png') }}"
title="Candidate pending review"
alt="Candidate pending review"/>
{% endif %}
</td>
Expand Down
6 changes: 6 additions & 0 deletions nuancier/templates/elections_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,23 @@ <h1>Elections</h1>
<td>
{% if election.submission_open %}
<img src="{{ url_for('static', filename='Approved.png') }}"
title="Submission open"
alt="Submission open"/>
{% else %}
<img src="{{ url_for('static', filename='Denied.png') }}"
title="Submission closed"
alt="Submission closed"/>
{% endif %}
{{ election.submission_date_start }}
</td>
<td>
{% if election.election_open %}
<img src="{{ url_for('static', filename='Approved.png') }}"
title="Election open"
alt="Election open"/>
{% else %}
<img src="{{ url_for('static', filename='Denied.png') }}"
title="Election open"
alt="Election open"/>
{% endif %}
{{ election.election_date_start }}
Expand All @@ -59,10 +63,12 @@ <h1>Elections</h1>
{% if election.election_public %}
<a href="{{ url_for('results', election_id=election.id) }}">
<img src="{{ url_for('static', filename='Approved.png') }}"
title="Election published"
alt="Election published"/>
</a>
{% else %}
<img src="{{ url_for('static', filename='Denied.png') }}"
title="Election closed"
alt="Election closed"/>
{% endif %}
{{ election.election_date_end }}
Expand Down
2 changes: 1 addition & 1 deletion nuancier/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from sqlalchemy.exc import SQLAlchemyError
## pylint cannot import flask dependency correctly
# pylint: disable=E0611
from werkzeug import secure_filename
from werkzeug.utils import secure_filename

import nuancier
import nuancier.lib as nuancierlib
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ blinker # required by flask for tests
dogpile.cache
flask
flask-wtf
flask-oidc
Pillow
python-fedora >= 0.3.33
python-openid
Expand Down