Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
Profile forms actually react
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpengi committed Jul 12, 2012
1 parent 1d4181f commit 9b65d78
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
4 changes: 2 additions & 2 deletions hicap/hicap/membership/forms.py
Expand Up @@ -29,7 +29,7 @@ class PasswordResetForm(forms.Form):
nonce = forms.fields.CharField(widget=forms.widgets.TextInput(attrs={"placeholder": "Nonce"}))
new_password = forms.fields.CharField(widget=forms.widgets.PasswordInput(attrs={"placeholder": "New Password"}))

def create_profile_form(meta):
def create_profile_form():
_TagsFields = {}
for field in profile_schema['tags']:
_TagsFields[field['id']] = forms.CharField(
Expand All @@ -49,7 +49,7 @@ def create_profile_form(meta):
)
_LinksForm = type("_LinksForm", (forms.Form,), _LinksFields)

return _LinksForm(), _TagsForm()
return _LinksForm, _TagsForm



12 changes: 9 additions & 3 deletions hicap/hicap/membership/views.py
Expand Up @@ -225,13 +225,19 @@ def community(cls, request, maker):
@require_maker_login
def profile(cls, request, maker):
meta = maker.profile_data
LinksForm, TagsForm = create_profile_form(meta)
LinksForm, TagsForm = create_profile_form()
if request.method == 'POST':
linksForm = LinksForm(request.POST)
tagsForm = TagsForm(request.POST)
else:
linksForm = LinksForm()
tagsForm = TagsForm()
context = {
'here': 'profile',
'maker': maker,
'meta': meta,
'links_form': LinksForm,
'tags_form': TagsForm,
'links_form': linksForm,
'tags_form': tagsForm,
}
return render_to_response("membership/profile.html", context, context_instance=RequestContext(request))

Expand Down
40 changes: 23 additions & 17 deletions hicap/hicap/templates/membership/profile.html
Expand Up @@ -16,25 +16,31 @@ <h1>Your Profile</h1>
{% if maker.is_public == False %}
<p class="alert">Your profile isn't public</p>
{% endif %}
<div class="row-fluid">
<div class="span6">
<hr>
<h2>Interests</h2>
{{ tags_form.as_p }}
<hr>
<form action="" method="POST">
{% csrf_token %}
<div class="row-fluid">
<div class="span6">
<hr>
<h2>Interests</h2>
{{ tags_form.as_p }}
<hr>
</div>
<div class="span6">
<hr>
<h2>Links</h2>
{% for field in links_form %}
<p>
{{ field.help_text }}
{{ field }}
</p>
{% endfor %}
<hr>
</div>
</div>
<div class="span6">
<hr>
<h2>Links</h2>
{% for field in links_form %}
<p>
{{ field.help_text }}
{{ field }}
</p>
{% endfor %}
<hr>
<div class="row-fluid">
<input type="submit" value="Save">
</div>
</div>
</form>
{% endblock body_content %}
{% block sidebar_content %}
{% include "membership/sidebar.html" %}
Expand Down

0 comments on commit 9b65d78

Please sign in to comment.