28 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
97f45ee2bf
forms: Implement form for uninstallation
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-08-29 08:28:39 -04:00
Sunil Mohan Adapa
b5273cccf7
forms: Fix regression with TLS domain form in quassel and tt-rss
Without the change, the list of domains in the app pages for tt-rss and quassel
is empty.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-12-04 16:40:07 -05:00
Joseph Nuthalapati
a912c867c8
names: Create a generic TLS domain selection form
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-11-21 19:04:35 -05:00
Sunil Mohan Adapa
99c2325206
user: Accommodate Django 3.1 change for model choice iteration
- Before Django 3.1, iterating the .choices for a field would yield (id, label)
tuples directly suitable for use with ChoiceFields. From Django 3.1, id is an
instance of ModelChoiceIteratorValue which helps to easily find the model
instance. In most cases, using the proxy works, but in our case, the value is
being hashed. Access the actual value of the field from the object to avoid this
issue.

- Cleanup widget for disabling individual checkboxes in a group

- When a form is submitted, 'disabled' input field is omitted by the browser
irrespective of its value. So, the last admin user, automatically add the
'admin' group to form values.

Tests:

- On Django 2.2 and Django 3.2 access the user edit page. The form should render
as before the change without errors.

- Test with the current user as the last admin user. The 'admin' checkbox should
be read-only.

- Test with the current user not as the last admin user. The 'admin' checkbox
should not be read-only.

- Add/remove non-admin groups and save the current/different user.

- Access the user edit page as non-admin user, the groups should be disabled.

- Give/take admin permission to/from a user other than current user.

- Take admin permission from current user.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-10-07 10:36:14 -04:00
Sunil Mohan Adapa
74214c18ae
*: Use Django gettext functions instead of ugettext
- ugettext functions will be removed in Django 4.0. Each use emits a warning
when running with Django 3.2. Since we have warnings enabled in developer mode,
we see quite a few messages because of this.

- ugettext is already a simple alias of gettext. So, no regressions are
expected.

Tests:

- Accessing an affected app in UI with Django 3.2 and Django 2.2 works fine.

- Using Django 3.2 there are no warnings related to removal of ugettext
functions.

- Ran regular unit tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-09-20 16:50:16 -04:00
Joseph Nuthalapati
21326cfe46
openvpn: Add functional tests for user group "vpn"
This is the first functional test which tests the permissions of a
non-administrator user in a group.

Some changes had to be made in the form shown in users module for this
to work. The id of each checkbox in the "Permissions" section is now
predictable based on the name of the group. For example, the id of the
checkbox for the group "vpn" is `id_group_vpn`. Changes are also made in
`CheckboxSelectMultipleReadOnly` form class for consistency, though it
is not being used by this functional test.

Some utility functions for functional tests have been moved out of users
module to be usable by other app modules for testing group permissions.

One additional utility function to skip creating user if it already
exists has been added. Not using this function wouldn't break the test
but using it saves some time.

Changed password format string to use `S` instead of `w` to support
special characters in password.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-11-25 13:15:19 -05:00
Alice Kile
0b5b384651
app: Separate app enable/disable form from config form
- Introduce new API to mark an app that it can't be disabled.

- Mark jsxc, storage, config, upgrade and firewall apps as can't be disabled.

- Fixed functional tests

- Replaced AppForm with forms.Form in all modules' forms.py.

- Remove app.template.js.

- Remove unused styles.

- Remove app status checks in form_valid of Deluge, Diaspora, Matrix, Ejabberd,
MediaWiki, Storage, Transmission, Quassel

- Purge unused is_enabled context variables (Ikiwiki)

- ejabberd: Minor cleanup in template

- jsxc: Cleanup unneeded overrides

- tahoe: Cleanup unnecessary overrides

Tests performed:

- For all apps affected, test enable/disable button works and submitting
configuration form works: with changes updates message and without changes
'settings unchanged' message.
  - avahi
  - bind
  - cockpit
  - SKIP: coquelicot
  - datetime
  - deluge
  - SKIP: diaspora
  - ejabberd
  - gitweb
  - i2p
  - infinoted
  - ikiwiki
  - matrixsynapse
  - mediawiki
  - minetest
  - minidlna
  - mldonkey
  - mumble
  - pagekite
  - privoxy
  - quassel
  - radicale
  - roundcube
  - SKIP: samba
  - searx
  - SKIP: shaarli
  - shadowsocks
  - ssh
  - tahoe
  - transmission
  - FAIL: tt-rss (not installable)
  - wireguard
- Deluge test that configuration changes when app is disabled work
- Quassel test that setting the domain works when app is diabled
- Transmission test that setting the domain works when app is diabled
- Ikiwiki create form works properly
- Enable/disable button appears as expected when enabled and when disabled
- Enable/disable button works without Javascript
- Functional tests work for affected apps, Tor and OpenVPN
- AppForm is removed from developer documentation
  - Forms reference
  - Customizing tutorial
- Test all apps using directory select form
  - Transmission
  - Deluge
- Visit each template that overrides block configuration and ensure that it is
loaded properly and the display is as expected.
- All apps that use AppView that are not tested above should not have an
enable/disable button. That is JSXC, update, config, firewall, storage, users.

Signed-off-by: Alice Kile <buoyantair@protonmail.com>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-03-29 09:42:31 +03:00
Sunil Mohan Adapa
9368504da5
*.py: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:38:55 +02:00
Alice Kile
eb83e00011
fix formatting issues
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-07 13:08:35 -05:00
Alice Kile
ec62f331b8
app: Implement toggle button in app page
- revamp the old form submission model to enable/disable apps into a
  simple toggle button
- provide backwards compatibility when javascript is disabled

Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2019-11-19 00:02:16 +05:30
Sunil Mohan Adapa
b684b07d11
names: Make all apps use new api to retrieve domain names
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-08-11 18:39:54 -04:00
Sunil Mohan Adapa
e4351b6b97
Introduce daemon component to handle systemd units
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-06-13 20:18:02 -04:00
Sunil Mohan Adapa
7ee4d13dce Show Gujarati in the list of UI languages
- Explicitly setup the list of Django languages. Keep them sorted by language
  code.

- Fallback to language name when Django can't provide locale language name.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-01-09 14:52:02 +05:30
Joseph Nuthalapati
b740a37a1e
users: Replace disabled with readonly for admin group checkbox
- Added validation logic in the backend to compensate

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-07-04 08:28:55 -04:00
Hemanth Kumar Veeranki
b9963a45cd
Restrict removal of last admin user
- Don't allow disabling the only available admin account.
- Don't allow deletion of the only available admin account.
- Don't allow removing admin privileges of the only available admin account.

Signed-off-by: Hemanth Kumar Veeranki <hems.india1997@gmail.com>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-06-21 20:09:02 +05:30
Sunil Mohan Adapa
6090d5c37d
locale: Split the language selection form into a mixin
- It may not be a good thing for the user created/edit forms to inherit from
  Django Form and ModelForm at the same time. So, simply by introducing a
  minimal mixin.

- Save only when committing.

- Use auto-saving feature.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-21 21:08:33 +01:00
Sunil Mohan Adapa
ef9e5c7a43
locale: Update the language selection form
- Add help text.

- Add docstring.

- Add better description for 'no choice'.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-21 21:07:31 +01:00
Sunil Mohan Adapa
b4f75ded79
locale: YAFP and isort formatting
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-21 21:06:20 +01:00
Sai Kiran Naragam
837e0b8384
locale: Adds preferred language for logged in user
- UserProfile model is created, it has one-to-one relationship with User.

- Language selection dropdown added to UserCreate and UserUpdate forms.

- Adds None to language selection dropdown to explicitly unselect.

- LANGUAGE_SESSION_KEY is set to User's preferred language on LogIn activity.

- LANGUAGE_SESSION_KEY is deleted on User's LogOut activity.

Signed-off-by: Sai Kiran Naragam <saikiran.rguiiit@gmail.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2018-02-21 21:06:14 +01:00
Sai Kiran Naragam
5cff5629d8
locale: Anonymous users can set preferred language
Logged-in user flow is pending.

Check [How django discovers language preference]:
https://docs.djangoproject.com/en/1.10/topics/i18n/translation/#how-django-discovers-language-preference

Signed-off-by: Sai Kiran Naragam <saikiran.rguiiit@gmail.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2018-02-21 21:06:07 +01:00
Sunil Mohan Adapa
dea4af17fb
Rename Plinth to FreedomBox in license headers
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:09 -05:00
Joseph Nuthalpati
4abb7cd885
Diaspora: Checkbox to enable or disable user registrations 2017-07-29 12:40:44 -04:00
Joseph Nuthalpati
5ad180fcc9
Add Tahoe-LAFS module
- Created basic plinth app which starts an introducer and a storage
  node on the FreedomBox.
- Prompt user to set a domain name before creating Tahoe-LAFS nodes.
- Support adding and removing of introducers to the storage node.
- Serve Tahoe-LAFS from a different port.
- Start all nodes and introducers at system startup.
- Add utility class YAMLFile with test cases.
2017-06-10 09:38:57 -04:00
morrme
ad3420823d
owncloud: Remove module (Closes: #818)
It is believed that ownCloud is unlikely to return to Debian in near future.
Removing module to ease maintenance.

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2017-04-25 18:06:56 +05:30
fonfon
f419c28596
Services: Explicitly use ServiceForm and ServiceView
- adapted all modules to not use views.ConfigurationView anymore
- removed templates that are not needed anymore
- no more implicit 'enabled' and 'get_status' functions in __init__.py files
- (more coherent/explicit use of Django functionality)
2016-05-11 18:19:31 -04:00
Sunil Mohan Adapa
fa8c2cf6ff
views: Add a common view for enabling applications
- A lot of boiler plate code can be removed from Plinth if enabling and
  disabling an application can be done using a common base form.

- This also allows to define a reusable method in an application for
  enabling and disabling.

- This brings more structure to a application module and paves way for
  having a different views such as dashboard.
2016-02-28 19:37:23 +05:30
fonfon
e905d1a8f2 packagekit: use TemplateView instead of FormView
For the installation procedure a TemplateView is sufficient, and the user
won't be able to edit any form-data on the client-side.
2015-01-05 00:27:45 +05:30
Sunil Mohan Adapa
a4be460538 Introduce framework for checking/installing packages
- Uses PackageKit dameon, Glib library wrapping packagekit DBUS API and
  Python bindings for the Glib library.

- Implement a decorator to wrap views requiring packages.

- Framework allows for parallel operations.  However, doing parallel
  operations hangs because of what appears to be PackageKit backend
  limitations.
2015-01-05 00:13:19 +05:30