ficlatte / main

Ficlatté website main code
GNU Affero General Public License v3.0
2 stars 2 forks source link

Refactor #34

Closed ethel-t-frog closed 6 years ago

ethel-t-frog commented 7 years ago

At the moment, pretty much all the code is in a single file (castle/views.py). This is not how Django is supposed to be structured, and it is not very good practice either.

We should create separate Django apps for authors, stories, prompts and challenges in order to make things much more managable. The url decoder should be made modular too, with each app handling its own urls.

Assigned to Jim, as he has kindly decided to take a look at this.

stitzelj commented 7 years ago

I've startled to fiddle with this just slightly. I made the mistake of starting work on it without backing up my database first and corrupted the whole damn thing and had to rebuild the database from scratch. I've learned from that error and now back it up at least daily. What I do know is that pulling apart the database schema to accommodate individual, smaller apps is going to be a wee bit tricky, so I've been putting it off a bit. I'll start digging into it again in a couple of days and try to work backward, starting with the Challenge module and see how much of a mess I can make of things before I figure out how to do it right. :)

ethel-t-frog commented 7 years ago

My instinct would be to leave the DB schema alone unless there is a compelling reason to change it. You can do

from castle.models import *

in other modules.

stitzelj commented 7 years ago

I considered that option, as well, and just breaking apart the views, urls, etc. files. Given your suggestion, that's probably the easiest and most straightforward approach.

stitzelj commented 7 years ago

The refactoring is done. There are new apps now for the blog, author, story, prompt, and challenge modules. I reorganized the castle.urls and the castle.views with what was leftover after the refactoring was done and cleaned things up for readability. It should be a lot easier now moving forward to work with the code now that it's been broken down into manageable chunks.

ethel-t-frog commented 7 years ago

Fantastic, thanks Jim.

stitzelj commented 7 years ago

I will note, too, that I left the submit_commit view in the castle.views file for now because it's no longer exclusive to just the story app and I didn't feel like it's large enough by itself at the moment to merit its own app. I have a couple of ideas for small additional features for comments I want to add a little further down the road, so I might throw it into an app of its own at that point with those additions.