{ "info": { "author": "Social TRM Ltd", "author_email": "david@socialtrm.com", "bugtrack_url": null, "classifiers": [], "description": "================================\nPopup forms framework for Django\n================================\n\nProblem\n-------\n\n* To have easy way to show popup window, holding any form,\n from any page of the website (examples: send message from user\n profile or from list of profiles; apply/withdraw to pool from\n list of companies, etc.)\n\n* This popup window should be pre-loaded, i.e. there should not\n be HTTP request to server in order to open popup window\n\n* In case form error occurs (some fields are missing,\n email format is wrong, etc.) the same form should be re-populated\n in the same page, indicating errors\n\n* After form is submitted, user should be redirected\n to either the same, or specified page\n\nSolution\n--------\n\nThe solution consists of 4 components:\n\n* Template tag, rendering popup form and link for opening it::\n\n {% popup_form 'id1' popup_forms.ApplyForm '/talent/apply/6/' 'popup_forms/apply_to_pool.html' %}\n {% popup_form 'id2' popup_forms.SomeModelForm '/talent/apply/6/' 'popup_forms/apply_to_pool.html' kwarg1=... kwarg2=... %}\n\n* Decorator for view function, that is processing popup form submission,\n and exception to handle form errors::\n\n import popup_forms\n\n @popup_forms.handler\n def form_view(request):\n if request.method == 'POST':\n form = ApplyForm(request.post)\n if not form.is_valid():\n return popup_forms.OpenFormResponse(request, form)\n # ...\n # ... FORM PROCESSING GOES HERE ...\n # ...\n return popup_forms.CloseFormResponse(request)\n else:\n return redirect('failure_url')\n # or raise Http404\n # or just popup_forms.CloseFormResponse(request)\n\n* Template to render the form, derived from popup_forms/base.html\n* (optional) context processor (popup_forms.context_processors.popup_forms),\n that puts all PopUp form classes to context, in order not to pass it each time in view:\n\n - in settings::\n\n POPUP_FORMS = ('messages.forms.WriteMessageForm',\n 'talentbutton.forms.ApplyForm',\n 'talentbutton.forms.ConfirmForm',)\n\n - in template it could be accessed::\n\n {{ popup_forms.WriteMessageForm }}, etc. \n\n* Decorator to conditionally display popup form on page load\n (for example, to fill in some missing information after registration/login)::\n\n @show_popup_form('/account/register/details/',\n lambda request: 'register-details' in request.session)\n def some_my_view(request):\n ...\n\n\nUse case is following:\n\n* Template tags renders the form, together with link::\n\n Link Title\n