[Freedombox-discuss] Easiest way to modify models.py and views.py for Plinth?
Sunil Mohan Adapa
sunil at medhas.org
Wed Jan 20 16:37:13 UTC 2016
On 01/17/2016 02:21 AM, Adrian Gropper wrote:
> Hello All,
> I have a FreedomBox up and running, and I want to modify the Django
> project Plinth that comes with my FreedomBox. I want to add one or more
> models (database tables), and I want to add some view functions and
> Eventually, I probably want to make this into a Debian package that can
> be installed easily by other FreedomBox users. That is ten steps down
> the road, right now I just want to modify my own single FreedomBox machine.
> I have seen the instructions here
> https://wiki.debian.org/FreedomBox/Manual/Developer, but I still have
> some rather basic questions:
> 1. I think I want to make a new Django app with my models.py, views.py,
> and template files. Then I want to add it to INSTALLED_APPS in
> settings.py and I will need to modify a few other files as described in
> the instructions above. Does this sound like the correct plan?
Yes, to add an App to Plinth, this is the approach. One correction is
that you don't have to add the app name to INSTALLED_APPS, Plinth does
it automatically based on a file in
/etc/plinth/modules-enabled/<appname> . See developer manual on this.
> 2. On my FreedomBox, where exactly is the settings.py file that is being
> used by Plinth? Where are the other files I will need to change? Should
> I just edit the files, save them, and make a note of what I added?
Django supports two mechanisms for initializing. One mechanism is to
the have a settings.py and another is to make a method call directly
with essentially the contents of settings.py. The former method is well
suited for most projects. Plinth, however, has to take command line
arguments and read configuration files before settings can be decided.
So, in Plinth, we take the latter approach of making a method call to
initialize Django with all settings pass manually.
You can find Django initialization happening in __main__.py. If you
have settings to change, you can do that over there. Names, meaning and
working of settings is as usual.
> 3. Examples to follow would be nice. Is there a simple and well-built
> Django app FreedomBox plugin that I can install, play with, and examine?
> Ideally something which adds at least one Django model and adds a tab to
> the Plinth admin interface.
You can find several applications in the plinth/modules directory. Each
module is a Django app on the lines of what you are building. You can
pick, say, quassel IRC application. It shows a bare minimum application
that adds menu items into the interface. You can see 'pagekite' and
'dynamicdns' as examples that add multiple page interface. 'firstboot'
module is an example for a adding wizard. There are no apps that add
models yet. However, you can see example of that in the main project
itself as plinth/models.py.
> (In case you’re wondering, I’m working on a project called HIE of One
> https://github.com/HIEofOne/PersonalAS/wikiwhere I need single-sign-on
> to FreedomBox first and will add the OAuth2 / UMA authorization server
> after that. I think eventually many FreedomBox users might appreciate an
> app that adds single-sign-on in order to have persistent accounts on the
> FreedomBoxes of their friends.)
Please feel free to ask further questions. You might get faster answers
by hanging around on the FreedomBox's IRC channel.
I have seen you request earlier for help on architecture bits. I have
spent some time understanding OAuth2, OpenID Connect etc. These
standards don't seem to have federation as one of their main goals while
it appears to be doable. For your case, it is also important to
understand what various health care providers are following as
standards. There seem to be quite a few standards in the area. So, I
don't understand everything fully.
I believe I will be able to help after more discussion. If it is
possible you to attend our FreedomBox monthly voice conference call, you
could perhaps explain us your plans and take feedback and architecture
inputs from the team. Otherwise, we can also catch up on the IRC.
Overall, I think HIE of One is an application that is very much in the
spirit of FreedomBox and could be an application that even non-technical
people could relate to. On top of this, having OAuth2/OpenID Connect as
way for users to maintain a single account on FreedomBox for services
provided elsewhere would be nice.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: OpenPGP digital signature
More information about the Freedombox-discuss