Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First part of refactoring the Dashboard to Django #616

Merged
merged 14 commits into from
Oct 23, 2024

Conversation

chrisarridge
Copy link
Contributor

This PR is a breaking change and is the first part of the refactor of the Dashboard to Django. The PR contains the following changes:

  • The Django project structure is generated and existing files moved into place. Some glue code is added so that folder paths can be easily be changed.
  • Logging and some refactoring is done on the static file generators (make_plots.py and make_csv.py).
  • The main navigation structure of the site is implement in Django.
  • The first part of the hierarchy (Headlines) is refactored.

The refactoring process requires implementation of view functions and setting up of URL routes, but also changes in the templates so that they work in Django. Optimisation of the view functions and app will be required once the site is fully refactored.

Code refactored so that any file/path that is needed is generated
using a central set of functions in config.py.  This has been done
as part of the refactor to Django so that the code can be moved
around and any changes in paths can be changed in just one place.
Moved source code (not including code to fetch data), templates and
static content into a dedicated source code folder to accommodate the
transition to Django's directory structure.  To make the Dashboard
work the path constants were updated in config.py and some small
path-related changes to the tests were applied so that they run in the
new location.
Added Django to requirements.in and recompiled both requirements
files.
Added basic Django project structure ready to be customised for
the Dashboard.  Doesn't really do anything right now but is ready
to flesh out with Dashboard views.
Renamed plots.py to make_plots.py to be consistent with make_csv.py.
Lightly refactored both scripts and added logging and progress bars
to aid in development work.  Required a minor change in requirements.
Also changed destination folders to suit new structure for static
files.
Created file for functions that are used in templates, and which
aren't filters or tags, into a separate file.  This commit moves
firstint() from make_html.py.
This commit implements a URL structure for the Dashboard and includes
views for the top level navigation of the Dashboard as well as the
main pages in the Headlines section.  This required changes in the
templates to remove Flask-specific template functions and minor
syntax changes that prevented rendering.  The views themselves will
eventually benefit from some optimisation.  Note, this commit is a
breaking change for make_html.py and now the repo will not generate
a Flask website.
Moved licence page generation code into views.py and created view
functions for the licenses page and the individual license detail page.
Small adjustments were made to the templates for them to work with Django.
Also moved license id code and title into text.py and added some license
data generation code into views.py.
Moved custom filters from make_html.py into this file.
Since these table fragments were included in other templates I decided
to move them into the _partials folder where other reusable components
were stored.
This commit completes the refactoring of the publisher headlines by
modifying the publisher template, adding some extra URL routes, and
completing the view function for the publisher detail page.  Also
needed a minor change to the boxes template.
Updated both the readme (including converting to markdown) and
contributors guide.  The readme now includes information on how to
run the Django version of the Dashboard.
For clarity in the repository this commit renames the directories
that store the source code.  All the source code in src/ was moved
to dashboard/.  Also, the actual Django app code was moved from
src/dashboard/ to dashboard/ui/.  This commit doesn't change the
import statements to make the app run, this will be done in the next
commit.
Change import statements and Django project strings to account for
moving the dashboard from dashboard/ to ui/.
@chrisarridge chrisarridge self-assigned this Oct 22, 2024
Copy link
Contributor

@Bjwebb Bjwebb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. I'm going to merge this, as I think it's okay to break the merge-codeforiati-and-publishingstats branch.

I see you've moved the licenses code into views.py, which is fine, but just a heads up that we might want to split that kind of thing out again if views.py gets too big.

@Bjwebb Bjwebb merged commit 0986915 into merge-codeforiati-and-publishingstats Oct 23, 2024
2 checks passed
@Bjwebb Bjwebb deleted the chris-django-refactor branch October 23, 2024 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants