Skip to content

Commit

Permalink
Merge branch 'hotfix/2.7.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
tienne-B committed Nov 27, 2022
2 parents 165bd5a + 6c430b8 commit f600de0
Show file tree
Hide file tree
Showing 21 changed files with 199 additions and 89 deletions.
15 changes: 14 additions & 1 deletion .github/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
Change Log
==========

2.7.2
-----
*Release date: 27 November 2022*

- Fixed crashes when creating ballots through the API (BACKEND-AM2)
- Don't re-capitalize side names in results tables
- Fixed printable ballots not appearing when in French
- Prevented malicious strings from breaking printable pages
- Added new instructions for deploying to Heroku using a fork and for applying for free student credits at Heroku
- Fixed sorting of unallocated draggable items
- Got regional colours to match between legend and donut charts


2.7.1
-----
*Release date: 6 November 2022*
Expand All @@ -16,7 +29,7 @@ Change Log


2.7.0 (Pixie-bob)
---------
-----------------
*Release date: 1 October 2022*

- Added the ability to deploy to Render as a 1-click Heroku-like deployment option
Expand Down
7 changes: 3 additions & 4 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ Our user guide is at [tabbycat.readthedocs.io](http://tabbycat.readthedocs.io/).

## ⬆️ Installation

Tabbycat can be deployed in a number of ways.
Tabbycat can be used in a number of ways.

[Calico](https://calicotab.com/) is a managed hosting service run by one of Tabbycat's developers. For a flat fee, it will host tab websites, automatically manage their setup and performance, and provide ongoing access to the released tab. Click this button to deploy to Calico:

[![Deploy](https://raw.githubusercontent.com/gist/tienne-B/fc04ecd3c11a38424b642b4bba60e8d9/raw/b2c71d7d6a0d368d3e9dfd8002af729d155ad09b/calicodeploy.svg)](https://calicotab.com/tournaments/new/)

Tabbycat is **no longer available as a 1-click Heroku installation**. If you do not want to use Calico, you have a few alternate options:
If you do not want to use Calico, you will need to setup and manage your own copy of Tabbycat:

1. For online tournaments where long-term data preservation is unnecessary, we have [a 1-click installer that uses the Render platform](https://tabbycat.readthedocs.io/en/stable/install/render.html) and runs within its free tier of services
1. For tournaments that require online access, you can [install and run Tabbycat from Heroku](https://tabbycat.readthedocs.io/en/stable/install/heroku.html). However, this will cost a small amount of money _unless_ you are a student and have registered for free Heroku hosting credits
2. For tournaments where online access is unnecessary, you can [install and run Tabbycat from your own computer](https://tabbycat.readthedocs.io/en/stable/install/local.html)
3. For online tournaments in general, you can still deploy to Heroku, [but will need to run a script from your computer's command line](https://tabbycat.readthedocs.io/en/stable/install/heroku.html)

## 💪 Support and Contributing

Expand Down
59 changes: 59 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "Tabbycat",
"description": "Debating tournament tabulation software for British Parliamentary and a variety of two-team parliamentary formats",
"repository": "https://github.com/TabbycatDebate/tabbycat",
"keywords": ["debate", "debating"],
"website": "https://tabbycat.readthedocs.io/",
"logo": "https://raw.githubusercontent.com/TabbycatDebate/tabbycat/develop/tabbycat/static/logo-48x48.png",
"addons": [
"papertrail",
"rediscloud:30",
"heroku-postgresql:mini",
{
"plan": "heroku-redis:mini",
"options": {
"maxmemory-policy": "allkeys-lru",
"timeout": 1800
}
}
],
"env": {
"DJANGO_SECRET_KEY": {
"description": "A secret key for cryptographic signing of user sessions.",
"generator": "secret"
},
"TAB_DIRECTOR_EMAIL": {
"description": "Your email address. Tabbycat's developers may need to contact you to help diagnose any unexpected errors.",
"value": ""
},
"TIME_ZONE": {
"description": "The time zone name in the IANA tz database for the tournament's location. Examples: America/Los_Angeles, Europe/Dublin, Africa/Johannesburg. You can look up yours in the 'TZ*' column at http://wikipedia.org/wiki/List_of_tz_database_time_zones#List",
"value": "Australia/Melbourne"
},
"DISABLE_COLLECTSTATIC": {
"description": "Leave this as-is.",
"value": "1"
},
"ON_HEROKU": {
"description": "Leave this as-is.",
"value": "1"
}
},
"formation": {
"web": {
"quantity": 1,
"size": "eco"
},
"worker": {
"quantity": 1,
"size": "eco"
}
},
"buildpacks": [
{ "url": "https://github.com/heroku/heroku-buildpack-nginx.git" },
{ "url": "heroku/nodejs" },
{ "url": "heroku/python" }
],
"stack": "heroku-22",
"success_url": "/start/"
}
8 changes: 4 additions & 4 deletions bin/post_compile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env bash

# Note that Heroku's node.js runtime instantiate before the python one
# The node.js buildpack will automatically run `npm run build`

set -eo pipefail

echo "-----> I'm post-compile hook"
Expand All @@ -10,10 +14,6 @@ python manage.py migrate --noinput
echo "-----> Running dynamic preferences checks"
python manage.py checkpreferences

echo "-----> Running static asset compilation"
npm install -g @vue/cli-service-global
npm run build

echo "-----> Running static files compilation"
python manage.py collectstatic --noinput -v 0

Expand Down
4 changes: 2 additions & 2 deletions config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

daemon off;
# Heroku dynos have at least 4 cores.
worker_processes 4;
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;

events {
use epoll;
accept_mutex on;
worker_connections 1024;
worker_connections <%= ENV['NGINX_WORKER_CONNECTIONS'] || 1024 %>;
}

http {
Expand Down
12 changes: 6 additions & 6 deletions deploy_heroku.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def get_random_secret_key():
help="Git branch to push (defaults to current branch)")

parser.add_argument(
"--pg-plan", "--postgresql-plan", type=str, default="hobby-dev",
help="Heroku Postgres plan (default hobby-dev)")
"--pg-plan", "--postgresql-plan", type=str, default="mini",
help="Heroku Postgres plan (default mini)")

parser.add_argument(
"--web-dynos", type=str, default="1:free",
help="Web dyno specification, passed to heroku ps:scale web=[], e.g. 1:free, 1:hobby, 2:Standard-1X")
"--web-dynos", type=str, default="1:eco",
help="Web dyno specification, passed to heroku ps:scale web=[], e.g. 1:eco, 1:hobby, 2:Standard-1X")

parser.add_argument(
"--import-tournament", type=str, metavar="IMPORT_DIR",
Expand Down Expand Up @@ -158,7 +158,7 @@ def get_git_push_spec():

# Create the app with addons
addons = ["papertrail", "heroku-postgresql:%s" % args.pg_plan, "rediscloud:30"]
command = ["heroku", "apps:create", "--stack", "heroku-18"]
command = ["heroku", "apps:create", "--stack", "heroku-22"]

if addons:
command.extend(["--addons", ",".join(addons)])
Expand All @@ -170,7 +170,7 @@ def get_git_push_spec():
heroku_url = match.group(2)

# Add the redis add-ons (the heroku one needs a config flag)
run_heroku_command(["addons:create", "heroku-redis:hobby-dev",
run_heroku_command(["addons:create", "heroku-redis:mini",
"--maxmemory_policy", "allkeys-lru", "--timeout", "1800"])

# Set build packs
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# The short X.Y version.
version = '2.7'
# The full version, including alpha/beta/rc tags.
release = '2.7.1'
release = '2.7.2'

rst_epilog = """
.. |vrelease| replace:: v{release}
Expand Down
53 changes: 47 additions & 6 deletions docs/install/heroku.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,55 @@ Installing on Heroku
.. admonition:: IMPORTANT
:class: error

Unfortunately, due to Heroku policy, the "Deploy to Heroku" button for Tabbycat will not work. If you are unable to use `Calico <https://calicotab.com>`_, you can try:
Recent changes by Heroku have altered how Tabbycat can be deployed on their service.

- Any of the Local installation methods
- Using the instructions below as an alternative way to create a Heroku site
- Our (in beta) `support for Render <render.html>`_, which uses a similar 1-click method
Heroku Deployments Overview
===========================

Heroku Deployments
==================
Tabbycat can be deployed to Heroku in two ways:

1. A fork-based method, that approximates a '1-click' install experience. Requires no technical background.
2. A script-based method, which requires running a python script on your local machine. Requires some technical background.

Regardless of method, please note that Heroku no longer offers a free tier of hosting services. However, students with an academic email address now have access to $13 USD worth of credits (per month) to use on the service if they enrol in the `GitHub Student Developer Pack <https://education.github.com/pack>`_. These credits will be sufficient to run 2-3 different tab sites simultaneously.

Please also note Heroku will require a debit/credit card to be attached to your account for verification purposes — even if you have free credits available. If using free credits, you should make note of the (annual) expiration of your GitHub student status and plan to either renew your status or cancel any Heroku services you don't want to pay for.

Heroku Deployments using a Fork
===============================

GitHub Account Setup
--------------------

1. Create an account at `GitHub <https://github.com>`_. If you are a student, be sure to register with your academic email address.
2. If you are a student: `sign-up to claim the Student Pack <https://education.github.com/pack>`_ so you will receive free Heroku credits. Note that it may take several days for the claim to process.

Heroku Account Setup
--------------------

1. Create an account at `Heroku <https://heroku.com>`_, or use an existing Heroku account.
2. Once your GitHub student status has been confirmed, use `the button here <https://www.heroku.com/github-students>`_ to claim your free monthly credits.

GitHub Fork and Deployment
--------------------------

In order to use a user-friendly '1-click deployment button', you will need to make a 'fork' (personal copy) of Tabbycat on Github. To do so:

1. Login to GitHub and go to `the main Tabbycat project page <https://github.com/TabbycatDebate/tabbycat>`_
2. Click the **Fork** button in the top-right
3. On the next page, **Uncheck** the button that says *Copy the develop branch only* then click **Create Fork**
4. The next page will show your copy of Tabbycat. Take note of your Github username and your fork's name in the top-left, e.g. **JaneSmith/tabbycat**
5. Open a new tab in your web browser and copy-paste in this URL *without hitting enter (yet)*:

::

https://heroku.com/deploy?template=https://github.com/YOUR_GITHUB_NAME/YOUR_FORK_NAME/tree/main

6. In the URL address, replace ``YOUR_GITHUB_NAME`` with your GitHub username (e.g. **JaneSmith**) and replace ``YOUR_FORK_NAME`` with the name of your fork (e.g. **tabbycat**)
7. Hit enter and fill out the details required. After the deployment process completes, you should have a new Tabbycat deployment

Heroku Deployments using the Deploy Script
==========================================

*We've tested these instructions successfully on Windows, Linux and macOS.*

Expand Down
5 changes: 5 additions & 0 deletions docs/install/render.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
Installing on Render
====================

.. admonition:: IMPORTANT
:class: error

Setting up Heroku on Render is currrently in beta and is somewhat unreliable. Use Heroku for a more reliable option.

Render is a web hosting platform, similar to Heroku. Like Heroku, it provides a similar '1 click' method of deployment that should be approachable to people without experience in deploying web applications. Support for deploying Tabbycat to Render is currently **in beta**.

.. admonition:: Warning
Expand Down
24 changes: 10 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"npm-run-all": "^4.1.5",
"popper.js": "^1.16.1",
"quagga": "0.12.x",
"sass": "^1.56.1",
"stats-percentile": "^3.3.0",
"vue": "^2.6.14",
"vue-cli-plugin-webpack-bundle-analyzer": "^4.0.0",
Expand All @@ -60,8 +61,8 @@
},
"browserslist": [
"> 1%",
"last 3 versions",
"not ie <= 11"
"last 1 version",
"not dead"
],
"engines": {
"node": "16.15.x",
Expand All @@ -71,7 +72,6 @@
"repository": "https://github.com/TabbycatDebate/tabbycat",
"version": "3.18.1",
"devDependencies": {
"eslint-plugin-html": "^6.2.0",
"sass": "^1.52.2"
"eslint-plugin-html": "^6.2.0"
}
}
6 changes: 3 additions & 3 deletions tabbycat/adjfeedback/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.functional import cached_property
from django.utils.html import escape
from django.utils.translation import gettext, gettext_lazy as _
from django_better_admin_arrayfield.models.fields import ArrayField

Expand Down Expand Up @@ -211,16 +212,15 @@ def construct_number_scale(self, min_value, max_value):

def serialize(self):
question = {
'text': self.text.replace("'", ""), # Escaping ' characters
'text': escape(self.text),
'seq': self.seq,
'type': self.answer_type,
'required': self.answer_type,
'from_team': self.from_team,
'from_adj': self.from_adj,
}
if self.choices:
choices = [c.replace("'", "") for c in self.choices]
question['choice_options'] = choices
question['choice_options'] = [escape(c) for c in self.choices]
elif self.min_value is not None and self.max_value is not None:
question['choice_options'] = self.choices_for_number_scale
return question
Expand Down
Loading

0 comments on commit f600de0

Please sign in to comment.