diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7166376e..61e13b26 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -25,6 +25,9 @@ // "remoteEnv": {"PATH": "/home/dev-user/.local/bin:${containerEnv:PATH}"}, "remoteUser": "dev-user", "workspaceFolder": "/app", + "forwardPorts": [ + 8000 // Github codespaces cant' detect this port automatically for some reason + ], "features": { "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} }, diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index ca4cd49f..00000000 --- a/.prettierignore +++ /dev/null @@ -1,3 +0,0 @@ -democrasite/templates/ -democrasite-frontend/lib/auto/ -schema.json diff --git a/LICENSE b/LICENSE index 747d5f0f..01d541f9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,5 @@ - The MIT License (MIT) -Copyright (c) 2024, Matthew Foster Walsh +Copyright (c) 2025, Matthew Foster Walsh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.rst b/README.rst index 3da9b750..3da9e8e7 100644 --- a/README.rst +++ b/README.rst @@ -1,13 +1,13 @@ Democrasite =========== -|Built with Cookiecutter Django| |Black code style| |Continuous integration| |Coverage report| |Documentation status| +|Built with Cookiecutter Django| |Ruff| |Continuous integration| |Coverage report| |Documentation status| .. |Built with Cookiecutter Django| image:: https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg?logo=cookiecutter :target: https://github.com/pydanny/cookiecutter-django/ -.. |Black code style| image:: https://img.shields.io/badge/code%20style-black-000000.svg - :target: https://github.com/ambv/black +.. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json + :target: //github.com/astral-sh/ruff .. |Continuous integration| image:: https://github.com/mfosterw/cookiestocracy/actions/workflows/ci.yml/badge.svg :target: https://github.com/mfosterw/cookiestocracy/actions/workflows/ci.yml @@ -23,8 +23,8 @@ Democrasite Democrasite is a website which automatically merges changes based on popular approval. For more information on the nature and purpose of the project, visit -our `about page`_. This page is meant for people who want to clone the -repository and contribute to the project. This project is approximately in beta +our `about page`_. This page is meant for people who want to fork the +repository and/or contribute to the project. This project is approximately in beta development (hence the repository being named "cookiestocracy" - a reference to cookiecutter and `kakistocracy`_). The alpha version is `here`_ and the full version doesn't exist yet. @@ -55,7 +55,7 @@ Getting Started The easiest way to explore the repository is to open it in GitHub Codespaces with the button above. Once you've given the container some time to set up (it should take about three minutes), navigate to the ports tab right above the terminal and hover over port -3000, then click on the browser icon that appears. You should see the development +8000, then click on the browser icon that appears. You should see the development version of the homepage! (With no data yet, see below). Please read the `contribution guide`_ to set up a local development environment with @@ -64,6 +64,20 @@ following the instructions in the guide. .. _`contribution guide`: https://cookiestocracy.readthedocs.io/en/latest/CONTRIBUTING.html +.. warning:: + Firefox's "advanced tracking protection" can cause problems connecting to the + codespace. If you are experiencing errors, you can disable it for that page by + clicking on the shield icon to the left of the URL and switching off Advanced + Tracking Protection + + +Understanding the repository +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Check out ``repo_map.txt`` in the root of the repository for a display of the +repository layout and brief explanations for the purpose of each non-obvious file and +directory. + Management Commands ------------------- @@ -80,7 +94,7 @@ Loading initial data To load some initial sample data into the database, run:: - $ python manage.py loaddata initial.json + $ python manage.py loaddata democrasite activitypub Setting up your users ^^^^^^^^^^^^^^^^^^^^^ diff --git a/config/settings/base.py b/config/settings/base.py index 3ddfeaed..4589fadd 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -1,5 +1,6 @@ """Base settings to build other settings files upon.""" +import warnings from pathlib import Path import environ @@ -36,8 +37,11 @@ # DATABASES # ------------------------------------------------------------------------------ +with warnings.catch_warnings(): + warnings.simplefilter("ignore") # environ raises an unhelpful warning here + db_url = env.db("DATABASE_URL", default=None) # https://docs.djangoproject.com/en/dev/ref/settings/#databases -if db_url := env.db("DATABASE_URL", default=None): +if db_url: DATABASES = {"default": db_url} else: DATABASES = { diff --git a/constitution.json b/constitution.json index fcd5eadc..af10324c 100644 --- a/constitution.json +++ b/constitution.json @@ -1,18 +1,13 @@ { "constitution.json": null, - "config/settings/base.py": [[340, 359]], - "config/urls.py": [[9, 16]], + "config/settings/base.py": [[412, 431]], + "config/urls.py": [[14, 33]], "democrasite/static/js/vote.js": null, "democrasite/templates/base.html": null, - "democrasite/users/models.py": [[7, 13]], - "democrasite/users/urls.py": null, + "democrasite/users/models.py": [[19, 35]], "democrasite/webiscite/constitution.py": null, - "democrasite/webiscite/models.py": [[11, 84]], - "democrasite/webiscite/tasks.py": [ - [43, 80], - [89, 96], - [112, 176] - ], - "democrasite/webiscite/urls.py": [[16, 22]], - "democrasite/webiscite/views.py": [[110, 133]] + "democrasite/webiscite/models.py": [[106, 439]], + "democrasite/webiscite/tasks.py": [[23, 78]], + "democrasite/webiscite/urls.py": [[10, 16]], + "democrasite/webiscite/views.py": [[127, 171]] } diff --git a/democrasite/contrib/__init__.py b/democrasite/contrib/__init__.py index 1c7ecc89..6b591244 100644 --- a/democrasite/contrib/__init__.py +++ b/democrasite/contrib/__init__.py @@ -1,5 +1,5 @@ """ To understand why this file is here, please read: -http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django +https://cookiecutter-django.readthedocs.io/en/latest/5-help/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django """ diff --git a/democrasite/contrib/sites/__init__.py b/democrasite/contrib/sites/__init__.py index 1c7ecc89..6b591244 100644 --- a/democrasite/contrib/sites/__init__.py +++ b/democrasite/contrib/sites/__init__.py @@ -1,5 +1,5 @@ """ To understand why this file is here, please read: -http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django +https://cookiecutter-django.readthedocs.io/en/latest/5-help/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django """ diff --git a/democrasite/contrib/sites/migrations/0003_set_site_domain_and_name.py b/democrasite/contrib/sites/migrations/0003_set_site_domain_and_name.py index f36b3bb3..e1fae039 100644 --- a/democrasite/contrib/sites/migrations/0003_set_site_domain_and_name.py +++ b/democrasite/contrib/sites/migrations/0003_set_site_domain_and_name.py @@ -1,7 +1,7 @@ """ To understand why this file is here, please read: -http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django +https://cookiecutter-django.readthedocs.io/en/latest/5-help/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django """ from django.conf import settings diff --git a/democrasite/contrib/sites/migrations/__init__.py b/democrasite/contrib/sites/migrations/__init__.py index 1c7ecc89..6b591244 100644 --- a/democrasite/contrib/sites/migrations/__init__.py +++ b/democrasite/contrib/sites/migrations/__init__.py @@ -1,5 +1,5 @@ """ To understand why this file is here, please read: -http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django +https://cookiecutter-django.readthedocs.io/en/latest/5-help/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django """ diff --git a/democrasite/static/css/webiscite.css b/democrasite/static/css/webiscite.css index 0b5dc104..9bd0af88 100644 --- a/democrasite/static/css/webiscite.css +++ b/democrasite/static/css/webiscite.css @@ -13,10 +13,6 @@ color: var(--red) !important; } -.git-pull-link { - text-decoration: none !important; -} - .progress { height: 5px; } diff --git a/democrasite/templates/pages/about.html b/democrasite/templates/pages/about.html index a78e83e4..a7f3da7a 100644 --- a/democrasite/templates/pages/about.html +++ b/democrasite/templates/pages/about.html @@ -12,14 +12,14 @@
- {% blocktrans %}This website is the epitome of user-generated content, of “web 2.0,” of social media. Everything on this website can be created, removed, or altered by any user, especially the site itself. All that you, the user, have to do in order to change or add something, is to create an account and then go to the GitHub page for this website, fork the project, and submit a pull request. A bill will automatically be created which you can see on the site. After that, it is up to your fellow users to vote on your proposed changes. If the majority of votes agree with you, the change will be automatically accepted and deployed to the live site. If they don’t, the pull request will be closed and you will have to try again. Anyone, regardless of technical knowledge and experience, can vote on these changes, and anyone who knows how to write Python can propose changes. This is the ultimate democratic technology, the only website where the site itself is user-generated. You, user, are invited to make this experiment into anything you like.{% endblocktrans %} + {% blocktrans %}This website is the epitome of user-generated content, of “web 2.0,” of social media. Everything on this website can be created, removed, or altered by any user, especially the site itself. All that you, the user, have to do in order to change or add something, is to create an account and then go to the GitHub page for this website (linked at the bottom of the homepage), fork the project, and submit a pull request. A bill will automatically be created which you can see on the site. After that, it is up to your fellow users to vote on your proposed changes. If the majority of votes agree with you, the change will be automatically accepted and deployed to the live site. If they don’t, the pull request will be closed and you will have to try again. Anyone, regardless of technical knowledge and experience, can vote on these changes, and anyone who knows how to write Python can propose changes. This is the ultimate democratic technology, the only website where the site itself is user-generated. You, user, are invited to make this experiment into anything you like.{% endblocktrans %}
- {% blocktrans %}Not everything can be decided by a mere majority. There are some changes that I consider so significant that they need more than half of the user base to support them before they are added. Code that, if changed, would radically alter the nature of the site is identified in a file within the repository called "constitution.json". Any proposals that change any of the lines protected by the the Constitution, which includes the Constitution itself, require at least a 2/3rds majority of votes cast in favor in order to pass. Like other legal constitutions, this document will ideally prevent controversial total overhauls or radical changes from occurring lightly or quickly. Any proposal is welcome to add or remove constitutional status from any file, but bear in mind that doing so is, by definition, a constitutional amendment, and will therefore trigger the supermajority requirement in order to pass. This means that guarding your own changes with the constitution will not be easy, and new changes are intentionally not as difficult to revert as major or core features of the website. This policy officializes the idea of "lock-in," where the core basis of a piece of technology or a group of technologies becomes much harder to change than later additions. This clearly has downsides, and my code is far from perfect and could benefit from other people editing it, but I deemed protecting the core functionality of the site and encouragin innovation and new additions more important.{% endblocktrans %} + {% blocktrans %}Not everything can be decided by a simple majority. There are some changes that I consider so significant that they need more than half of the user base to support them before they are added. Code that, if changed, would radically alter the nature of the site is identified in a file in the root of the repository called "constitution.json". Any proposals that change any of the lines protected by the Constitution, which includes the Constitution itself, require at least a 2/3rds majority of votes cast in favor in order to pass. Like other legal constitutions, this document will ideally prevent controversial total overhauls or radical changes from occurring lightly or quickly. Any proposal is welcome to add or remove constitutional status from any file, but bear in mind that doing so is, by definition, a constitutional amendment, and will therefore trigger the supermajority requirement in order to pass. This means that guarding your own changes with the constitution will not be easy, and new changes are intentionally not as difficult to revert as major or core features of the website. This policy reinforces the idea of "lock-in," where the core basis of a piece of technology or a group of technologies becomes much harder to change than later additions. This clearly has downsides, and my code is far from perfect and could benefit from other people editing it, but I deemed protecting the core functionality and purpose of the site and encouraging new additions more important.{% endblocktrans %}
- {% blocktrans %}This website is, obviously, inspired by the ideas of democratic governance, or government "by the people." In particular, it serves as a direct democracy, where every proposed law or policy change is put to a popular referendum, letting the citizens, or users, make every decision about how the site will be governed. The difference between this website and a real country is that the governance, the day-to-day running of the institutions, is done automatically by the code that is on the server implemented, which obviously cannot subvert the intentions of the users who approve that code, as opposed to the myriad of people required to maintain a nation, with varying degrees of power and each with their own goals and agendas. Despite this major caveat, this website was inspired by real government, and I hope it can go on to inspire governments in exchange. The use of Git version control has been immensely powerful for “open-source,” or community developed, software, by allowing anyone to submit improvements for a project maintainer to review and approve if they help the project. This website replaces the step of approval by a maintainer, or authority figure, with approval by the user base, or general public. Real law codes could undergo a similar shift with tools made possible by the internet. Already several local and state governments have begun experimenting with publishing laws on Github, and some even let the public submit proposals through it, such as fixing some phrasing on government websites. These places are just beginning to understand the potential that these tools create, and I hope that this project can help to demonstrate that potential. Git seems especially powerful for the process of “codification,” or combining all the pieces of legislation passed into a unified code of laws which can be used as a general reference. This is usually undertaken by unelected government officials, who can and have made mistakes. Git allows anyone to propose fixes or additions to such a code, as well as including tools such as blame to let everyone see who changed any part of the code. Regardless of how changes come about, it is clear the impact that the internet will have on systems of government has barely begun to be realized.{% endblocktrans %} + {% blocktrans %}This website is inspired by the ideas of democratic governance, or government "by the people." In particular, it serves as a direct democracy, where every proposed law or policy change is put to a popular referendum, or “plebiscite”, letting the “citizens” (aka users) make every decision about how the site will be governed. The difference between this website and a real country is that the governance, the day-to-day running of the institutions, is done automatically by whatever code is deployed to the server. Code obviously cannot intentionally subvert the intentions of the users who approve that code, as opposed to the myriad of people required to maintain a nation, with varying degrees of power and each with their own goals and agendas. Despite this major caveat, this website was inspired by real governments, and I hope it can serve as a real-world analogue to inspire governments in exchange.{% endblocktrans %} +
++ {% blocktrans %}The use of distributed version control software, namely Git, has been immensely powerful for “open-source,” or community developed, software, by simplifying the process for maintainers to review and include contributions by the community. This website replaces the step of approval by a maintainer, or any central authority figure, with approval by the user base. Real law codes could undergo a similar shift with tools made possible by the internet. Already several local and state governments have begun experimenting with publishing their legal codes as Git repositories, and Washington DC even lets the public submit proposals through Github. These places are just beginning to understand the potential that these tools create, and I hope that this project can help to further demonstrate that potential. Git seems especially powerful for the process of “codification,” or combining all the pieces of legislation passed into a unified code of laws which can be used as a general reference. This is usually undertaken by unelected government officials, who can and have made mistakes. Git allows anyone to propose fixes or additions to such a code, as well as including tools such as blame to let everyone see who changed any part of the code. Tools like this one could facilitate the next generation of government transparency, encouraging public participation and political accountability. + {% endblocktrans %}