Re: Dynamic AUTH_USER_MODEL based on modules or routes

2013-10-08 Thread Russell Keith-Magee
On Wed, Oct 9, 2013 at 6:16 AM, Burak Emre Kabakcı wrote:

> It would be nice if you allow using two different models for
> django.contrib.auth module. The current User model is great for admin panel
> users but in frontend it may become extra overhead for some cases. People
> try to create another user attribute models and use extra joins to be able
> to keep extra attributes (city, ip, locale etc.) for their users.
>
> It seems there are a lot of improvements in Django 1.5 I think there are
> more thing that may be revised. For example I think we should be able to
> set AUTH_USER_MODEL setting per module basis or namespaced routes basis.
>
> In order to solve this issue I needed to create a middleware class to
> change settings.AUTH_USER_MODEL; however I know that this is not the ideal
> solution because in each request I need to re-set one of the static Django
> settings. Here is the middleware class:
>
> class ChangeBaseUser(object):
> def process_request(self, request):
> match = resolve(request.path)
> if match.app_name == "myapp":
> settings.AUTH_USER_MODEL = 'myapp.Customer'
> else:
> settings.AUTH_USER_MODEL = 'auth.User'
>
>  Hi Burak,

Thanks for the suggestion, but I think you need to think through the
consequences of this a little more. AUTH_USER_MODEL isn't just a setting --
it controls the way that foreign keys are constructed in the database. Once
a foreign key is constructed, it can't be (easily) pointed at a completely
different table. It *certainly* can't switch between tables on a
per-request basis.

It sounds to me that what you have is *two* different applications, using
two different user models. Those two applications might share a lot of
other logic, including models, views, and so on -- but that's why Django
promotes the idea of reusable apps. You can write two apps, deployed at two
different paths on the same domain, that share 95% of their logic, and only
vary on a small number of settings or additional apps - like an
AUTH_USER_MODEL setting.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAJxq848oaWHZ%2BCjJmiNYfh2uNi%2BqZs7ye_tje6%3D8sZAkSXZcCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Dynamic AUTH_USER_MODEL based on modules or routes

2013-10-08 Thread Andre Terra
Hi, Burak,

I'm not sure if you're problem is one of too much cruft in
*frontend-related code* or in *user-facing content* but, in any case, it
seems to me that "there should be one-- and preferably only one --obvious
way to do it." [0]

Moreover, If you're having to deal with complex models for simple tasks in
frontend code, you can use proxy models[1] and/or custom managers[2]. If
OTOH you're problem is exposing too much functionality to users, then it
would be up for you to refactor your code (especially forms) to better
target your users' needs.

Finally, Django shouldn't try to provide every feature for every use case,
lest it becomes flexible at the expense of "excellency", for the lack of a
better word. I'm not sure this is a problem for most Django users, so the
cost of having an extra middleware for a fringe use-case seems non-trivial
to me.

With all this in mind, I respectfully propose that this issue be handled at
the project/app level rather than by the framework as a whole.


Cheers,
AT

[0] http://www.python.org/dev/peps/pep-0020/
[1] https://docs.djangoproject.com/en/dev/topics/db/models/#proxy-models
[2]
https://docs.djangoproject.com/en/dev/topics/db/managers/#custom-managers-and-inheritance


On Tue, Oct 8, 2013 at 7:16 PM, Burak Emre Kabakcı wrote:

> It would be nice if you allow using two different models for
> django.contrib.auth module. The current User model is great for admin panel
> users but in frontend it may become extra overhead for some cases. People
> try to create another user attribute models and use extra joins to be able
> to keep extra attributes (city, ip, locale etc.) for their users.
>
> It seems there are a lot of improvements in Django 1.5 I think there are
> more thing that may be revised. For example I think we should be able to
> set AUTH_USER_MODEL setting per module basis or namespaced routes basis.
>
> In order to solve this issue I needed to create a middleware class to
> change settings.AUTH_USER_MODEL; however I know that this is not the ideal
> solution because in each request I need to re-set one of the static Django
> settings. Here is the middleware class:
>
> class ChangeBaseUser(object):
> def process_request(self, request):
> match = resolve(request.path)
> if match.app_name == "myapp":
> settings.AUTH_USER_MODEL = 'myapp.Customer'
> else:
> settings.AUTH_USER_MODEL = 'auth.User'
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/bd88babe-684e-4b5a-8b90-86963c40ffd5%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAKBiv3x9d_HwAkhkL27O0YTPgnTTAFt_z0FY-sJ0j0n9CY95Kw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Dynamic AUTH_USER_MODEL based on modules or routes

2013-10-08 Thread Burak Emre Kabakcı
It would be nice if you allow using two different models for 
django.contrib.auth module. The current User model is great for admin panel 
users but in frontend it may become extra overhead for some cases. People 
try to create another user attribute models and use extra joins to be able 
to keep extra attributes (city, ip, locale etc.) for their users.

It seems there are a lot of improvements in Django 1.5 I think there are 
more thing that may be revised. For example I think we should be able to 
set AUTH_USER_MODEL setting per module basis or namespaced routes basis.

In order to solve this issue I needed to create a middleware class to 
change settings.AUTH_USER_MODEL; however I know that this is not the ideal 
solution because in each request I need to re-set one of the static Django 
settings. Here is the middleware class:

class ChangeBaseUser(object):
def process_request(self, request):  
match = resolve(request.path)
if match.app_name == "myapp":
settings.AUTH_USER_MODEL = 'myapp.Customer'
else:
settings.AUTH_USER_MODEL = 'auth.User'


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/bd88babe-684e-4b5a-8b90-86963c40ffd5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Design discussion: admin alert messages

2013-10-08 Thread Ryan Allen
Here are comparisons for several different color blindness types: 
http://imgur.com/a/JaLPD

On Tuesday, October 8, 2013 3:16:32 AM UTC-4, HM wrote:
>
> Did you test the colors with a color-blind filter? Always a question to 
> ask when red and green is given significance in any way. The new error red 
> is better though, bigger contrast to the white.
>
>
>
> On 7 October 2013 22:44, Ryan Allen wrote:
>
>> https://github.com/django/django/pull/1715
>>
>> Currently, all admin messages have a background color of light yellow, 
>> whether they are success message, warning message, or error message. Errors 
>> are displayed with red (#F00) text.
>>
>> This pull request would give success messages a green background and 
>> errors a light red with dark red border and text.
>>
>> Current alerts: http://imgur.com/a/dIO6O
>> Updated alerts: http://imgur.com/a/fw54u
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-develop...@googlegroups.com .
>> To post to this group, send email to 
>> django-d...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-developers.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/2ab5f4ee-16df-4bf2-8d3e-893885d51f39%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/b8d7b998-562b-436e-9e75-27106596b4a5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Design discussion: admin alert messages

2013-10-08 Thread Ryan Allen
Here are comparisons for several different color blindness 
types: http://imgur.com/a/JaLPD



On Tuesday, October 8, 2013 11:57:08 AM UTC-4, Ryan Allen wrote:
>
> Thanks, I found a Chrome extension to use - 
> https://chrome.google.com/webstore/detail/spectrum/ofclemegkcmilinpcimpjkfhjfgmhieb?hl=en
>
> On Tuesday, October 8, 2013 9:37:35 AM UTC-4, Daniele Procida wrote:
>>
>> On Tue, Oct 8, 2013, Ryan Allen  wrote: 
>>
>> >Good thought, I'll get some color test screenshots put together today. 
>>
>> I've used  which I thought was quite 
>> good, but perhaps you know of better ones. 
>>
>> Daniele 
>>
>>
On Tuesday, October 8, 2013 11:57:08 AM UTC-4, Ryan Allen wrote:
>
> Thanks, I found a Chrome extension to use - 
> https://chrome.google.com/webstore/detail/spectrum/ofclemegkcmilinpcimpjkfhjfgmhieb?hl=en
>
> On Tuesday, October 8, 2013 9:37:35 AM UTC-4, Daniele Procida wrote:
>>
>> On Tue, Oct 8, 2013, Ryan Allen  wrote: 
>>
>> >Good thought, I'll get some color test screenshots put together today. 
>>
>> I've used  which I thought was quite 
>> good, but perhaps you know of better ones. 
>>
>> Daniele 
>>
>>
On Tuesday, October 8, 2013 11:57:08 AM UTC-4, Ryan Allen wrote:
>
> Thanks, I found a Chrome extension to use - 
> https://chrome.google.com/webstore/detail/spectrum/ofclemegkcmilinpcimpjkfhjfgmhieb?hl=en
>
> On Tuesday, October 8, 2013 9:37:35 AM UTC-4, Daniele Procida wrote:
>>
>> On Tue, Oct 8, 2013, Ryan Allen  wrote: 
>>
>> >Good thought, I'll get some color test screenshots put together today. 
>>
>> I've used  which I thought was quite 
>> good, but perhaps you know of better ones. 
>>
>> Daniele 
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/d800641d-a4aa-4300-9a91-23c6f504739e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Design discussion: admin alert messages

2013-10-08 Thread Ryan Allen
Thanks, I found a Chrome extension to use 
- 
https://chrome.google.com/webstore/detail/spectrum/ofclemegkcmilinpcimpjkfhjfgmhieb?hl=en

On Tuesday, October 8, 2013 9:37:35 AM UTC-4, Daniele Procida wrote:
>
> On Tue, Oct 8, 2013, Ryan Allen  wrote: 
>
> >Good thought, I'll get some color test screenshots put together today. 
>
> I've used  which I thought was quite 
> good, but perhaps you know of better ones. 
>
> Daniele 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/d6642fc7-f53a-4bb5-9e42-3efc9d940164%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Design discussion: admin alert messages

2013-10-08 Thread Daniele Procida
On Tue, Oct 8, 2013, Ryan Allen  wrote:

>Good thought, I'll get some color test screenshots put together today.

I've used  which I thought was quite good, but 
perhaps you know of better ones.

Daniele

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/20131008133736.887872701%40smtp.ntlworld.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Design discussion: admin alert messages

2013-10-08 Thread Ryan Allen
Good thought, I'll get some color test screenshots put together today.


On Tuesday, October 8, 2013 3:16:32 AM UTC-4, HM wrote:
>
> Did you test the colors with a color-blind filter? Always a question to 
> ask when red and green is given significance in any way. The new error red 
> is better though, bigger contrast to the white.
>
>
>
> On 7 October 2013 22:44, Ryan Allen wrote:
>
>> https://github.com/django/django/pull/1715
>>
>> Currently, all admin messages have a background color of light yellow, 
>> whether they are success message, warning message, or error message. Errors 
>> are displayed with red (#F00) text.
>>
>> This pull request would give success messages a green background and 
>> errors a light red with dark red border and text.
>>
>> Current alerts: http://imgur.com/a/dIO6O
>> Updated alerts: http://imgur.com/a/fw54u
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-develop...@googlegroups.com .
>> To post to this group, send email to 
>> django-d...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-developers.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/2ab5f4ee-16df-4bf2-8d3e-893885d51f39%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/a4b6c839-c4f1-4dee-80a0-c8a2ab217434%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Design discussion: admin alert messages

2013-10-08 Thread Hanne Moa
Did you test the colors with a color-blind filter? Always a question to ask
when red and green is given significance in any way. The new error red is
better though, bigger contrast to the white.



On 7 October 2013 22:44, Ryan Allen  wrote:

> https://github.com/django/django/pull/1715
>
> Currently, all admin messages have a background color of light yellow,
> whether they are success message, warning message, or error message. Errors
> are displayed with red (#F00) text.
>
> This pull request would give success messages a green background and
> errors a light red with dark red border and text.
>
> Current alerts: http://imgur.com/a/dIO6O
> Updated alerts: http://imgur.com/a/fw54u
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/2ab5f4ee-16df-4bf2-8d3e-893885d51f39%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CACQ%3DrrffHFa-58qenoM-5kryqYK0hDCM7Kcz0MK6fSTXU-OYbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.