Skip to content
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.

Issue #265 - user panel control #288

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

Naltharial
Copy link
Contributor

#265: Added basic support for users to select which panels they should show. Dependencies checked on form validation.

TODO: Required/recommended extension for inter-panel dependencies.

@@ -0,0 +1,22 @@
import random
Copy link
Member

Choose a reason for hiding this comment

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

Why additional panel? You could just in original panel file extend another panel class and register it. To reduce duplication. So, use inheritance.

@Naltharial
Copy link
Contributor Author

Changed the form to metaclass, changed the Panels model. Not sure why Issue #278 has a double-nested MapField, however. Or why we're passing number_of_columns as an argument. So right now, each user has a list of their panels and every panel can be collapsed and is at exactly one (column,order) position.

@mitar
Copy link
Member

mitar commented Sep 14, 2012

Based on the width of the window, number of columns for panels change. So we have double nested mapfiled because we are storing layout of panels for each number of columns there is. So once we map panel id to Panel. And then we map number of columns to PanelState, which tells where for this number of columns panel is.

@mitar
Copy link
Member

mitar commented Sep 14, 2012

So you will have to fix this. :-)

@Naltharial
Copy link
Contributor Author

Added the second MapField. I've just pulled collapsed out of PanelLayout, because it's not connected to number of columns.

@mitar
Copy link
Member

mitar commented Sep 16, 2012

Not true. It can be. If you have very narrow window on your laptop, you might not want to display all panels. You do not want them to be removed, but just collapsed. On your big monitor on your PC, you have more columns and you want all of panels to be shown fully.

@Naltharial
Copy link
Contributor Author

Well, sure, it just wasn't connected currently the way the JavaScript part is set up (requests to panel/collapse/ do not include number_of_columns). I can connect it, but that would mean changing the JavaScript behind it, which I thought was part of another issue.

@mitar
Copy link
Member

mitar commented Sep 16, 2012

OK. You decide. So I am explaining why model was proposed in the way it was. It is true that current code does not behave like that. But the end it should. So you can fix it yourself, or add TODO/ticket for this.

@Naltharial
Copy link
Contributor Author

Added the number to the requests for collapse and changed the model.

"""
Form for selecting homepage panels.
"""
__metaclass__ = PanelFormMetaclass
Copy link
Member

Choose a reason for hiding this comment

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

Empty line after docstring.

@Naltharial
Copy link
Contributor Author

I've replaced the get_columns method, the frontend does seem to work even with new panels that haven't been ordered yet. I had to use panels_pool in view though, because otherwise you don't get dependencies for panels that aren't currently selected.

Test cases also seem to pass now.

"""
This class holds panel instances for a user, their properties and layouts.

:param dict layout: mapping of count of displayed columns (`string`) to `PanelState` objects for that count
Copy link
Member

Choose a reason for hiding this comment

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

Now I noticed. This is not really a param. You use this when commenting functions and which parameters they take. In this case this is a class. and even class constructor does not take this parameter.

You might simply move this line above layout definition bellow and just leave it as a in-code-only comment.

@mitar
Copy link
Member

mitar commented Oct 15, 2012

the frontend does seem to work even with new panels that haven't been ordered yet.

Yes. This is good. So probably only frontend should decide how to order new panels. Not backend

I had to use panels_pool in view though, because otherwise you don't get dependencies for panels that aren't currently selected.

I agree. But we had get_all_panels method or something on user object before, why is that one not good? It can return for now the same list as panels_pool. But later on it could be limited (by, for example, permissions (debug panel could be available only to developers), or payment (we could have some panels available only if you buy them)).

@mitar
Copy link
Member

mitar commented Oct 15, 2012

Feature-wise, things are good now. So just check all your code for possible tabs and fix indentations and this is ready to go in.

There is one minor detail you can do, if you want, or open a ticket. You have to enable for elements before submit. But this is ugly as it changes user feedback and maybe confuses her. So some other solution should be used. What Internet recommends? Maybe a hidden input could be inserted which is kept in sync with checkbox? Maybe each checkbox could have its own hidden input all the time, kept in sync. JavaScript could rename all checkboxes and add hidden input box instead with that form name.

@Naltharial
Copy link
Contributor Author

I've added a second set of hidden inputs, so we don't have to un-disable the checkboxes. They're IntegerField, because hidden checkboxes don't properly submit state.

data_box = panel.get_name()
display_box = data_box + "_display"

attrs[data_box] = forms.IntegerField(required=False, initial=0)
Copy link
Member

Choose a reason for hiding this comment

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

Why not BooleanField, too?

@Naltharial
Copy link
Contributor Author

Fixed.

attrs[display_box] = forms.BooleanField(label=data_box, required=False)

# Connect display checkbox to data field
attrs[display_box].widget = forms.CheckboxInput(attrs={'data-panel':data_box, 'data-display':'True'})
Copy link
Member

Choose a reason for hiding this comment

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

Spaces after :.

Copy link
Member

Choose a reason for hiding this comment

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

Why are you settings widget from outside and not through the constructor? Set it through the constructor, it is much cleaner (and it might be better handled, you never know if there is some special handling when passed through constructor which you are bypassing now).

@mitar
Copy link
Member

mitar commented Oct 29, 2012

You had some problems with link property? Or you just didn't upgrade from requirements.txt?

@mitar
Copy link
Member

mitar commented Nov 6, 2012

I moved account Django app to separate Python package. You will have to update this pull request.

https://github.com/mitar/django-mongo-auth

@mitar
Copy link
Member

mitar commented Nov 10, 2012

OK, now everything should work with external authentication package.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants