On 5/1/06, Luke Plant <[EMAIL PROTECTED]> wrote:
>
> On Monday 01 May 2006 20:03, Sam Tran wrote:
>
> > I am having the problem described in ticket 1045:
> > http://code.djangoproject.com/ticket/1045
> >
> > Was this problem fixed in Django 0.91?
>
> It was closed as a WONTFIX, so I doubt it (the patch certainly has not
> been applied).  The problem you are having is inherent in HTML forms,
> and the solution is to have a view function that knows what data should
> have been filled in.
>

Hi Luke,

Thank you for the information.

However I am not sure how I would write such a view.

Here is my model:

class hierarchy_usr(meta.Model):
        id = meta.AutoField(primary_key=True)
        mgr_id = meta.CharField(maxlength=20, db_column="mgr_id")
        usr_id = meta.CharField(maxlength=20, db_column="usr_id")
        inherits = meta.BooleanField(blank=False, default=False)

I want to represent all manager/user relationships. For a given
relationship, if 'inherits' is True, then the manager inherits the
user's permissions.

I want to edit each manager/relationship by turning off or on, the
'inherits' boolean variable.

Here is the view I wrote so far:

def edit(request, mgr_id, usr_id):
  # Get the h_usr in question from the database and create a
  # ChangeManipulator at the same time.
  h_usr_obj = get_object_or_404(hierarchy_usrs,
                                mgr_id__exact=mgr_id,
                                usr_id__exact=usr_id)
  try:
    manipulator = hierarchy_usrs.ChangeManipulator(h_usr_obj.id)
  except hierarchy_usrs.DoesNotExist:
    raise Http404

  if request.POST:
    new_data = request.POST.copy()

    new_data['mgr_id'] = str(mgr_id)
    new_data['usr_id'] = str(usr_id)

    errors = manipulator.get_validation_errors(new_data)
    if not errors:
      manipulator.do_html2python(new_data)
      manipulator.save(new_data)

      # Do a post-after-redirect so that reload works, etc.
      #return HttpResponseRedirect(request.path)
      return HttpResponseRedirect("/access/hierarchy_usr/")
  else:
    errors = {}
    # This makes sure the form accurate represents the fields of the h_usr.
    new_data = manipulator.flatten_data()

  form = formfields.FormWrapper(manipulator, new_data, errors)
  return render_to_response('access/hierarchy_usr_edit', {'form': form})

I would appreciate any help.

Thanks.
Sam

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to