Commit Graph

35 Commits

Author SHA1 Message Date
b405302d97 Avoid returning HttpServerError for things not server errors
With the new django, alerts are raised for everything with status 500,
not juse exceptions. This put a light on a number of places where we
were returning 500 server error code for things that are not actually
server errors. Some should be a regular 200 ok with an error message,
and others should be a permissions error.
2020-04-04 14:43:27 +02:00
46606e5284 Set on_delete=models.CASCADE on all ForeignKey fields
This is the bardware compatible value that will be needed once we
upgrade django later.
2020-03-31 22:34:51 +02:00
69923c7190 Stop using bare exceptions
This is frowned upon in newer versions of pep8, so fix it once and for
all.
2020-01-09 13:14:32 +01:00
a156829375 Generic unicode updates 2019-01-26 16:19:26 +01:00
7547b6f766 Update syntax for relative imports 2019-01-26 16:19:26 +01:00
e3ec36b50c Remove multi-statement lines, per pep8 2019-01-17 20:52:17 +01:00
0883ac6423 Fix whitespace and indentation, per pep8 2019-01-17 20:47:43 +01:00
87237f6536 Tabs, meet your new overlords: spaces
In a quest to reach pep8, use spaces to indent rather than tabs.
2019-01-17 15:35:39 +01:00
e62309a391 Fix typos in comments
Review by Stephen Frost and Jonathan S. Katz
Discussion: https://postgr.es/m/6EEB2B47-D274-4E65-83B1-2EF8C917C55F%40yesql.se
2018-12-04 21:51:08 +01:00
0c6099e236 Remove unused imports 2018-06-29 13:40:04 +02:00
487d86bee3 Fix that HttpServerError now takes a request as parameter 2018-03-10 10:54:13 -05:00
fd37389a3b Replace NavContext and render_to_response with render_pgweb
render_to_response does not work on newer django, so it needs to be
replaced. And using a speicfic context actually overcomplicates things,
it's easier to just use a wrapper function. For those cases where we
don't need NavContext, just use render() (the new shortcut function from
django), which also removes the need to use RequestContext.
2018-03-10 10:38:11 -05:00
2f52c4f7c4 Clean up whitespace in primary Python / HTML files
Clean up the whitespace in the primary Python / HTML files in
order to make it easier to apply changes going forward.
2017-11-29 08:21:35 -05:00
0a93c65f20 Purge /community/ when changing a survey
Without this only the survey result page is purged, not the actual
survey form on the main page.
2016-12-14 15:25:02 +01:00
a8500c3853 Add migrations for all existing models
When migrating on existing installations, run the

python manage.py migrate --fake-initial

command.
2016-05-14 19:49:12 +02:00
217f9ef62a Fix model warnings and deprecations
1. ForeignKey with unique -> OneToOneField
2. IPAddressField -> GenericIPAddressField
3. Fix fields with default=datetime.now() which gives server start time,
   not the insert time (clearly this default was never used, and the
   field was always explicitly set, but it should still not be incorrectly
   defined)
2016-05-14 19:49:12 +02:00
856dbd31a2 Update for new transaction handling in newer django versions 2016-05-14 19:49:12 +02:00
8058accee0 Get rid of PgModel, replacing it with simple signals
We were already using signals for everything except delete, and even
in our old version of django the delete signal exists (it didn't exist
when this code was first written).

Django doesn't really like models to be OOP like this, so keeping PgModel
would cause issues with upcoming changes in django 1.8. Using simple functions
is easier, and the actual functionality is replicated straight off.
2016-03-07 21:41:45 +01:00
94e3b79dce Replace wildcard imports with explicit ones 2014-01-01 16:33:52 +01:00
756aa6ffbe Clean up imports
Remove unused imports and some other completely unused code.
2014-01-01 15:42:30 +01:00
ac0905a07c Also ensure unmanaged transaction is committed after purge 2013-10-19 15:47:32 +02:00
9633db3a4e Make explicit cache purge on survey votes
It should have been done through the model, but that is somehow not working.
Therefor, make an immediate purge of the results to the specific survey that
is being voted on.
2013-10-19 15:09:47 +02:00
f6fd1f2e97 Enable CSRF protection by default
Most of these forms look pretty benign, but the user profile form, which
includes an SSH key field, certainly needs to be protected.

The survey form is unprotected because it's served over insecure HTTP
and the Varnish proxy strips cookies, which is required by the builtin
CSRF protection.

Marti Raudsepp
2012-11-05 14:10:39 +01:00
ad895a7661 Can't leave an empty struct, need to actually remove it completely 2012-01-14 16:08:14 +01:00
5c6cd80006 This URL doesn't actually exist... 2012-01-14 12:41:29 +01:00
5bcbf1253e All purge_urls must be rooted, since we add ^ at the beginning 2011-11-27 13:31:20 +01:00
91d6cce18f Render server errors with a nicer template 2011-08-17 20:28:03 +02:00
af82e7cb87 When voting on a survey without a vote, redirect to results
instead of showing an error. This is now the same behaviour as the old site.
2011-08-16 21:00:59 +02:00
9893136c98 Properly order surveys on list 2011-08-16 13:58:27 +02:00
6b621f5ec7 Add migration script for surveys
In passing, make answers up to 500 characters, because that's required
to perform the migration of existing ones...
2011-08-16 13:58:03 +02:00
f92709d2a6 Implement basic varnish purging
This allows all models inherited from PgModel to specify which
URLs to purge by either setting a field or defining a function
called purge_urls, at which point they will be purged whenever
the save signal is fired.

Also implements a form under /admin/purge/ that allows for manual
purging. This should probably be extended in the future to show
the status of the pgq slaves, but that will come later.

Includes a SQL function that posts the expires to a pgq queue. For
a local deployment, this can be replaced with a simple void function
to turn off varnish purging.
2011-06-14 19:48:48 +02:00
22f5578c29 Add support for generating sitemap.
Each module now contains a struct.py file that will return all
the URLs that it can generate (yes, this is a small break of the
abstraction of url.py, but we've broken that elsewhere as well),
and also which search-engine-weight (0.1-1.0) that this URL should
be given.
2010-09-28 16:12:13 +02:00
bd167b0afa Redirect the user back to the *survey*, not the answer (which usually meant
redirecting to the wrong survey since the ids can't be mixed)
2010-06-17 14:58:03 +02:00
2942c2832a Use new get_client_ip() function instead of using REMOTE_ADDR. 2010-06-17 14:56:26 +02:00
2f671fe3d6 Add support for surveys 2009-12-28 16:12:44 +01:00