Design help

2011-03-23 Thread Ajay
Hi all,

I have a flow which I am not sure how to design with maximum reuse of
existing apps/features.

Flow :-
1) A non registered user comes and uploads his profile - (NOTE - there
is no user sign up form,only profile upload form).
2) Admin comes , approves the profile, edits it if he wants and then
assign it a profile id. Activates the profile.
3) Upon activation a mail is sent to the user (email id is provided in
the profile), with his profile id(which will be his username) and a
random password which he can change from site.


Additional Requirement :-
a) User wants to change his profile information, he edits it and saves
it but his profile information is not yet changed.
b) Changes should go to admin, if he approves the changes then new
profile information is saved, else he can reject the changes.


I am not sure how to do this especially the editing profile part.

My first attempt is like this:
a) create profile model and use generic create_update view to upload
the profile. Add a field of is_active.
b) Admin filters on basis of is_active and assigns them a profile_id.
c) Admin then goes on to create a user with that profile id as the
username and a FIXED password e.g. "changeit".
d) Admin then goes to the profile and then associates the profile with
the user.

Things that I am trying to figure are :
a) how to send the mail with credentials ? Can I use signals ?
b) how to make sure that in this process some user is not missing his
profile and some profile is not activated and still missing user? Can
I make some sort of filter in admin for this?
c) How to allow the editing of profile to be monitored by admin?


I am open for completely new flow :- only unchangeable requirements
are:
1. user can login only after admin has approved his profile and he
must be sent a mail once approved.
2. new profile of user can be saved only after approval by admin.

Sorry for the long mail.

Regards
Ajay

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Multiple different user profile objects - Django code design help

2009-02-20 Thread Gok Mop

On Feb 20, 6:07 am, Beres Botond  wrote:
> To be honest I don't really see why you would need multiple user
> profile models,
> instead of having one user profile model, and each entry would define
> a different
> user profile.

What do you mean by "one user profile model, and each entry would
define a different user profile"?

Do you mean to have my single user profile model have many foreign
keys hanging off of it pointing to other models?

Or do you mean have a single user profile model with lots of instance
data?

Imagine an app where you have users who are teachers, students, or
parents.  You track different information about teachers (which
courses they teach) vs. parents (relationship to student mom/dad,
etc).

I wouldn't want to cram all of that stuff into a single user profile
model and then have to figure out which sets of fields apply at
runtime.  If it's just instance data and isn't a foreign key to
another model, then it won't persist over time.

Right?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple different user profile objects - Django code design help

2009-02-20 Thread Beres Botond

To be honest I don't really see why you would need multiple user
profile models,
instead of having one user profile model, and each entry would define
a different
user profile.

Of course I don't know the full details/requirementes of your project,
and what exactly you are
trying to do ... but I cannot think of a reason off the top of my
head, why multiple user profile
*models* would be really necessary.




On Feb 20, 4:12 am, Gok Mop  wrote:
> On Feb 19, 6:39 pm, Andrew Ingram  wrote:
>
> > Simplest solution : don't worry about the AUTH_PROFILE_MODULE setting.
>
> > I'm working on a site with numerous modules that contain user account
> > information, such as orders and newsletter preferences. I just have a
> > foreignkey to the auth User on each of these, eg:
>
> > class OrderAccount(models.Model):
> >     user = models.ForeignKey(User,related_name="order_account")
>
> > class NewsletterAccount(models.Model):
> >     user = models.ForeignKey(User,related_name="newsletter_account")
>
> Sounds like a good idea...thanks.
>
> > Then, when you're interacting with a user model you can get any of your
> > account models with user.order_account or user.newsletter_account.
>
> This is the part that I'm not sure about though.  So let's say I have
> 4 objects that all take this same approach.  (Call them foo, bar, baz,
> and quux).  Then one of my views gets a user object, and needs to
> figure out which attached object is relevant.  (There's only one
> possibility).  Does that mean that I have to do:
>
> myobj = user.foo_account
> if myobj == None: myobj = user.bar_account
> if myobj == None: myobj = user.baz_account
> if myobj == None: myobj = user.quux_account
>
> ?
>
> In short, how do I tell which field I should be accessing?  Only one
> will be non-None.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple different user profile objects - Django code design help

2009-02-19 Thread Gok Mop

On Feb 19, 6:39 pm, Andrew Ingram  wrote:
> Simplest solution : don't worry about the AUTH_PROFILE_MODULE setting.
>
> I'm working on a site with numerous modules that contain user account
> information, such as orders and newsletter preferences. I just have a
> foreignkey to the auth User on each of these, eg:
>
> class OrderAccount(models.Model):
>     user = models.ForeignKey(User,related_name="order_account")
>
> class NewsletterAccount(models.Model):
>     user = models.ForeignKey(User,related_name="newsletter_account")

Sounds like a good idea...thanks.

> Then, when you're interacting with a user model you can get any of your
> account models with user.order_account or user.newsletter_account.

This is the part that I'm not sure about though.  So let's say I have
4 objects that all take this same approach.  (Call them foo, bar, baz,
and quux).  Then one of my views gets a user object, and needs to
figure out which attached object is relevant.  (There's only one
possibility).  Does that mean that I have to do:

myobj = user.foo_account
if myobj == None: myobj = user.bar_account
if myobj == None: myobj = user.baz_account
if myobj == None: myobj = user.quux_account

?

In short, how do I tell which field I should be accessing?  Only one
will be non-None.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple different user profile objects - Django code design help

2009-02-19 Thread Malcolm Tredinnick

On Thu, 2009-02-19 at 14:53 -0800, Gok Mop wrote:
> I'm struggling with how to design something, and I'm pretty sure
> somebody has an easy solution.
> 
> I need to store different information about different classes of
> users.  I want to attach those classes as the user profile to my
> django.contrib.auth.User object, so I can always cross-walk from the
> User object to my profile object, and vice versa.  The trouble is that
> I have more than 1 profile object.
> 
> My multiple profile objects share a common superclass:
> 
> class MyPerson(models.Model):
> user = models.ForeignKey(User, unique=True)
> (...handful of other things...)
> 
> (In settings, I specify AUTH_PROFILE_MODULE="myapp.myperson")
> 
> I then have 4-5 objects that extend MyPerson and tack on all the stuff
> specific to that object.
> 
> When I create users and associate profiles, that works great.  When I
> 'restore' a user from the database and ask for the profile, I get a
> MyPerson object, and I've lost the linkage to my subclass...and I'm up
> a river.  

You get back the MyPerson object because that's the model you've
specified as the profile class. Django's model inheritance does *not*
automatically descend to the most derived child class instance. There
are a number of good reasons for that, all covered in other threads on
both this list and django-developers.

You can still descend to the child classes, since they're linked via
one-to-one fields, so it's a reverse relation access. Or you could
include a type field in the MyPerson model that indicates the type of
the child model, so that you know immediately which type of model it is.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple different user profile objects - Django code design help

2009-02-19 Thread Andrew Ingram

Simplest solution : don't worry about the AUTH_PROFILE_MODULE setting.

I'm working on a site with numerous modules that contain user account 
information, such as orders and newsletter preferences. I just have a 
foreignkey to the auth User on each of these, eg:

class OrderAccount(models.Model):
user = models.ForeignKey(User,related_name="order_account")
 
class NewsletterAccount(models.Model):
user = models.ForeignKey(User,related_name="newsletter_account")

Then, when you're interacting with a user model you can get any of your 
account models with user.order_account or user.newsletter_account.

Regards,
Andrew Ingram

Gok Mop wrote:
> I'm struggling with how to design something, and I'm pretty sure
> somebody has an easy solution.
>
> I need to store different information about different classes of
> users.  I want to attach those classes as the user profile to my
> django.contrib.auth.User object, so I can always cross-walk from the
> User object to my profile object, and vice versa.  The trouble is that
> I have more than 1 profile object.
>
> My multiple profile objects share a common superclass:
>
> class MyPerson(models.Model):
> user = models.ForeignKey(User, unique=True)
> (...handful of other things...)
>
> (In settings, I specify AUTH_PROFILE_MODULE="myapp.myperson")
>
> I then have 4-5 objects that extend MyPerson and tack on all the stuff
> specific to that object.
>
> When I create users and associate profiles, that works great.  When I
> 'restore' a user from the database and ask for the profile, I get a
> MyPerson object, and I've lost the linkage to my subclass...and I'm up
> a river.  Particularly since I need some of the subclass information
> and methods in order to make access decisions for the User.
>
> Suggestions?  Any pointers would be very helpful.
> Thanks
>   

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multiple different user profile objects - Django code design help

2009-02-19 Thread Gok Mop

I'm struggling with how to design something, and I'm pretty sure
somebody has an easy solution.

I need to store different information about different classes of
users.  I want to attach those classes as the user profile to my
django.contrib.auth.User object, so I can always cross-walk from the
User object to my profile object, and vice versa.  The trouble is that
I have more than 1 profile object.

My multiple profile objects share a common superclass:

class MyPerson(models.Model):
user = models.ForeignKey(User, unique=True)
(...handful of other things...)

(In settings, I specify AUTH_PROFILE_MODULE="myapp.myperson")

I then have 4-5 objects that extend MyPerson and tack on all the stuff
specific to that object.

When I create users and associate profiles, that works great.  When I
'restore' a user from the database and ask for the profile, I get a
MyPerson object, and I've lost the linkage to my subclass...and I'm up
a river.  Particularly since I need some of the subclass information
and methods in order to make access decisions for the User.

Suggestions?  Any pointers would be very helpful.
Thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model design help

2007-07-28 Thread James Bennett

On 7/28/07, Cole Tuininga <[EMAIL PROTECTED]> wrote:
> I could do something like a simple many to many relationship in the
> attendee model, but that doesn't indicate ordering (most preferred to
> least preferred) per timeslot.

You might want to look at thisL

http://www.djangoproject.com/documentation/0.96/models/m2m_intermediary/

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model design help

2007-07-28 Thread oggie rob

When you use a ManyToMany field, a "private" table (not tied to a
model like other tables) is created in the database with something
like the following (created via the contrib.auth.User's
user_permissions field:
id, user_id, permission_id

If you wanted to create your own table that mirrors this one (i.e. has
two fields, "user" and "permission"), then you have the equivalent of
ManyToMany. You can also add other fields (e.g. "order"). The big
difference between this approach and using M2M are the methods you use
to access information in those tables, otherwise they are equivalent.
In fact, if you have an existing M2M field you can convert it to this
approach without much difficulty.

HTH,
 -rob

On Jul 28, 11:00 am, "Cole Tuininga" <[EMAIL PROTECTED]> wrote:
> Hey all - I was hoping I could solicit some help with a model design.
> I'm using 0.96 rather than the svn version at the moment.
>
> I'm working on a website for my wife that is intended to help with
> taking registrations for a conference.  The idea is that each workshop
> in the conference has a "timeslot" attribute.  Obviously, multiple
> sessions can point at the same timeslot.  Timeslots are also models so
> that as the conference is organized, my wife can alter them through
> the admin interface.
>
> When a person registers, they are asked to select their top three
> choices of workshops for each timeslot.  The thing is that as the
> timeslots are variable, I'm having trouble figuring out how I should
> set up the relationship between the attendee and the selected
> workshops.
>
> I could do something like a simple many to many relationship in the
> attendee model, but that doesn't indicate ordering (most preferred to
> least preferred) per timeslot.
>
> Have I explained this well enough?  Anybody have thoughts?
>
> --
> Cole Tuiningahttp://www.tuininga.org/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Model design help

2007-07-28 Thread Cole Tuininga

Hey all - I was hoping I could solicit some help with a model design.
I'm using 0.96 rather than the svn version at the moment.

I'm working on a website for my wife that is intended to help with
taking registrations for a conference.  The idea is that each workshop
in the conference has a "timeslot" attribute.  Obviously, multiple
sessions can point at the same timeslot.  Timeslots are also models so
that as the conference is organized, my wife can alter them through
the admin interface.

When a person registers, they are asked to select their top three
choices of workshops for each timeslot.  The thing is that as the
timeslots are variable, I'm having trouble figuring out how I should
set up the relationship between the attendee and the selected
workshops.

I could do something like a simple many to many relationship in the
attendee model, but that doesn't indicate ordering (most preferred to
least preferred) per timeslot.

Have I explained this well enough?  Anybody have thoughts?

-- 
Cole Tuininga
http://www.tuininga.org/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---