62 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
2a3381415e
Prioritize stronghold over admin require middlerware
Not logged-in users accessing restricted URLs will be required to
login page instead of being show access denied page.
2017-02-15 21:08:00 +05:30
Sunil Mohan Adapa
dd5ab7612e
Minor refactoring and lint fixes
- Rename AdminMiddleware to AdminRequiredMiddleware to be consistent
  with stronghold/Django terminology

- Simplify .gitignore pattern

- Format single line docstrings as per PEP8.

- Add missing docstrings.

- Restrict lines to 79 characters.
2017-02-15 21:07:27 +05:30
Sunil Mohan Adapa
4699b201a9
Remove use of stronghold whitelisting
This is no longer necessary as both the URLs have been explicitly
marked as public views.
2017-02-15 21:07:19 +05:30
lispyclouds
3e0f7a007e
Update default page after login
- This fixes the redirect to the index page instead of apps:index post
  login
2017-02-15 20:58:05 +05:30
lispyclouds
3b23f78bdc
Implement middleware for admin views
- Add AdminMiddleware to deny non admin users
- Add decorator to mark views as "non admin"
2017-02-15 20:57:52 +05:30
James Valleroy
70a858597a
Refactor module list command 2016-12-14 15:32:44 -05:00
mridulnagpal
fac840ec48
Add command line argument to list modules 2016-12-14 14:34:04 -05:00
Sunil Mohan Adapa
375f594808
Add argument to list packages needed by apps 2016-09-17 13:48:46 -04:00
Sunil Mohan Adapa
8ce6312190
Tune log message verbosity
It is no longer very important to show Django configured applications
and module import messages because in practice we have rarely ever seen
being useful anywhere but for development.  Just print the module load
order just once.
2016-09-17 13:48:42 -04:00
Sunil Mohan Adapa
314eddfcae
Print django migrate messages only in debug 2016-09-17 13:48:39 -04:00
Sunil Mohan Adapa
b097731e40
setup: Fix arguments to setup without install
- When arguments are passed to --setup-no-install, use them correctly.

- Explicitly initialize member in constructor

- Minor indentation
2016-09-03 11:28:58 +05:30
James Valleroy
548e0ebd60
Add --setup-no-install command
Acts the same as --setup, but does not install any packages. Will
raise an error if any required package is not already installed.
2016-09-03 10:02:54 +05:30
Sunil Mohan Adapa
2f1fe8af22
Remove unused setting LOGOUT_URL
Django 1.10 officially does not use the setting LOGOUT_URL anymore.
Django stronghold incorrectly uses it as a URL rather than named url.
2016-08-11 18:02:56 -04:00
Sunil Mohan Adapa
0856d7b090
Work around script prefix problem in stronghold 2016-08-11 18:02:48 -04:00
Hemanth Kumar Veeranki
42e44ec689
Fixed issue with lost menus in Django 1.10 2016-08-11 18:02:36 -04:00
Sunil Mohan Adapa
69a7f847aa
Properly fix setup argument checking 2016-08-01 20:38:42 +05:30
Hemanth Kumar Veeranki
29d20265c1
Removed a small bug of running setup always 2016-08-01 18:58:00 +05:30
Hemanth Kumar Veeranki
60e808e9bb
Added option for plinth --setup
Now plinth --setup could take a list of modules to setup
2016-07-31 14:15:57 +05:30
Sunil Mohan Adapa
9078ec5a2b
Don't write to PID file
When running under systemd, PID is known and maintained by systemd.
Process don't have write PIDs to a PID file.
2016-05-29 21:07:07 +05:30
Sunil Mohan Adapa
1f53321b51
Don't use init.d file, don't daemonize
We pretty much only run in systemd environment and I don't see that
changing any time soon.  By relying on it, we can reduce some burden.
Remove init script.

Daemonizing is not needed for systemd.  Remove code related
daemonization.
2016-05-29 20:32:12 +05:30
Sunil Mohan Adapa
d72abb8539
config: Don't restrict supported languages
- There is no reason to limit the number of languages supported by the
  application.  This is what happens when LANGUAGES is set during Django
  configuration.  Users should be able to set a language using browser
  preferences and see at least the Django translated messages even if
  Plinth messages are not translated (example user create/edit form).

- If we wish to limit the number of language options shown duing
  language selection (for quality perception reasons), we should perform
  the limiting at the time of configuration.

- Note that when a new language is requested in translation tool, we
  create an empty file and that may lead to language being shown but
  with few strings actually translated.  This will have poor impact on
  user experience.  I wonder if we should filter language at all,
  keeping this in mind.
2016-02-26 00:46:09 +05:30
James Valleroy
88c649d310
Handle _ in language codes. 2016-02-26 00:46:02 +05:30
Sunil Mohan Adapa
2c836046a6
main: Add command argument to setup essential apps
- The --setup argument sets up all applications that declare themselves
  as essential.

- This is done synchronously.

- Plinth exits after the setup is complete.

- Plinth fails with an error in case any of the setup tasks fail.  The
  process will be continued on next invocation or access of application
  from UI.
2016-02-13 13:50:20 +05:30
Sunil Mohan Adapa
8dcafe3e0e
middleware: New middleware to check need for setup
- Call the setup helper to check if a installation or update of a module
  is required.

- Show installation and progress using the setup view.
2016-02-13 13:50:16 +05:30
Sunil Mohan Adapa
7f4c5f7410
Make app names as module identifiers
- The last part of the module import path is the module name.  This also
  becomes the Django app name.  Apps names have to be unique.  Hence,
  there is no scope for two different modules with same name but
  different load path to exist in the project.

- Most uses of list of loaded modules are dealing with app names instead
  of full module load path.  This is due to the fact that Django deals
  with app names and not module paths.

- It is also somewhat clumsy to access a loaded module as we are
  re-importing every time to get access module.

- Simplify all of the above by using app names are module identifiers
  and maintaing an ordered dictionary of app names to loadded modules.

- Remove unused imports.

- Minor styling fixes.
2016-02-13 13:49:23 +05:30
Sunil Mohan Adapa
a1d5486c82 config: Refactor for easy testing
- Split the read method into two separate methods for getting the config
  file and for reading config file.

- Use logging module for printing error.

- Fix global variable naming.

- Get/set/show the realpath of the config file.

- Convert config items into a list so that the order is more
  predictable.  This is the reason for unpredictable failures in test
  cases.
2015-12-05 09:51:50 -05:00
Sunil Mohan Adapa
db548a4e24 Make migration work for older version upgrades
With the --fake-initial argument to migrate, Django will detect the
existance of initial table with the precondition that the table schema
must be the same as the first migration (it is in this case).

https://docs.djangoproject.com/en/1.8/topics/migrations/#adding-migrations-to-apps
2015-12-05 09:33:23 -05:00
Sunil Mohan Adapa
e6117fbcdf Update TEMPLATES setting for Django 1.8+ 2015-12-05 09:33:23 -05:00
Sunil Mohan Adapa
a432e16ed7 Use migrate management command instead of syncdb
- syncdb has been deprecated in Django 1.7 in favor of migrate command.

- In Django 1.9 it has been removed.  Django 1.9 has already hit Debian
  unstable.
2015-12-05 09:33:23 -05:00
fonfon
aeaa6ab800 Adds a 'language' dropdown field to the system configuration
- The language choice is stored with the session, not persistently
- This removes confirmation messages if nothing was changed
2015-11-18 18:29:54 +01:00
Sunil Mohan Adapa
139db064a9 Enable localized numbers and dates 2015-11-13 21:18:37 +05:30
Sunil Mohan Adapa
6c3c863619 Enable switching locale on a per-request basis 2015-11-13 21:18:04 +05:30
Sunil Mohan Adapa
45fd4f2a53 Cleanup casting from values in cfg 2015-09-29 22:50:02 +05:30
Sunil Mohan Adapa
38fe07cd93 help: Serve FreedomBox manual
- Remove FAQ menu entry

- Remove Wiki entry and place a link from index page.

- Update index content to point to IRC, wiki, manual and mailing list.
2015-09-27 09:49:45 -04:00
Sunil Mohan Adapa
0febeb7244 diagnostics: Add --diagnose command line option
- When this option is provided, Plinth will initialize, load modules,
  execute diagnostics, print the results on console and quit.

- Replacement for /usr/lib/freedombox/testsuite
2015-08-29 06:22:01 -04:00
Sunil Mohan Adapa
2b1b60fba5 Minor coding styling update in main.py 2015-08-29 06:22:01 -04:00
Sunil Mohan Adapa
6fd04808d5 Don't require login for logout page & minor fixes 2015-07-01 07:57:21 +05:30
fonfon
824a9091c1 use django-stronghold for authentication handling (instead of @login_required) 2015-07-01 00:01:02 +05:30
Maximiliano Curia
8418713741 Remove unneeded extra server 2015-06-08 21:44:55 +02:00
Maximiliano Curia
24fe6131fc Use the cherrypy autoreload feature only in debug mode
Small devices like the raspberry pi end up eating a number of resources (~20%
of the CPU according to top, even more if something else is increasing the
load, together with tor they eat ~70% of the cpu "on idle" ~50% for plinth
and ~20% for tor) stat the files once per second.
2015-06-08 13:13:29 +02:00
Sunil Mohan Adapa
e09018fe9a Fix issues with configuration/parameters loading
- Change default server directory from plinth/ to /plinth as the program
  expects.

- First load the values from configuration file and then override them
  with command line parameters.

- Show default values on the command line help.

- Use configuration file values as default values to command line
  parameters.

- Log the value of script prefix (server_dir) for easy debugging.

- Make sure the server_dir is properly loaded from configuration files.
2015-04-07 22:43:25 +05:30
Sunil Mohan Adapa
3fcbb36a21 Serve /usr/share/javscript on /javascript
Since the links to javascript libraries have been removed in favor of
using javscript-common, it is no longer possible to run Plinth stand
alone without a reverse proxy that also serves /javscript.  This patch
fixes that.  Now /javascirpt is also available when Plinth is running
stand alone.
2015-01-25 01:50:31 +05:30
Sunil Mohan Adapa
baa9205852 Fix issue with styling of error messages with bootstrap3 2015-01-25 01:17:58 +05:30
Sunil Mohan Adapa
90203986f2 Remove modules 'expert_mode' and 'lib'.
The login/logout URLs are now in the 'users' module.
2014-12-14 17:26:05 +05:30
fonfon
96a14e3d0d moved 'in-app menu' from the sidebar to the top of the content; some template block renaming 2014-12-06 17:08:37 +05:30
Sunil Mohan Adapa
1b6969a8a6 Rethink how proxied headers are handled
- Request Apache to send X-Forwarded-Proto header.

- Use X-Forwarded-Proto header to understand original protocol
  requested.

- Use X-Forwarded-Host header to understand original host requested.

- Allow any incoming host header so that FreedomBox can have any
  hostname and when user requests for Plint with that hostname, it
  works.

- Don't depend on Apache to rewrite the Location: header.  Instead use
  the original host and original scheme to set proper Location: header.
2014-11-30 15:11:50 +05:30
Sunil Mohan Adapa
fcc1330318 Relicense __main__.py to AGPLv3+
- There is no point in keeping this one single file as with different
  license from the rest of the package.  This change simplifies things.

- The file has been almost entirely been rewritten for Django, module
  loading, CherryPy static directories etc.

- This change will be pushed with the consent of new authors: fonfon and
  Me.
2014-11-30 14:49:49 +05:30
Sunil Mohan Adapa
4637bba3eb Print debug message about static directories served 2014-10-20 00:22:33 +05:30
fonfon
699a3ac0dc fixed static_dir of modules; omit hidden files in modules_enabled directory 2014-10-20 00:14:09 +05:30
Sunil Mohan Adapa
fc2fdc4d27 Turn modules into proper Django applications 2014-10-04 13:43:22 +05:30