Skip to content

Commit

Permalink
Claned up the style/display of the aggregator add form, and also adde…
Browse files Browse the repository at this point in the history
…d a bit

better permission checking.
  • Loading branch information
jacobian committed Jan 27, 2011
1 parent 68acbaa commit 39f9764
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 14 deletions.
14 changes: 8 additions & 6 deletions django_website/aggregator/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
from .models import Feed, FeedType

class FeedModelForm(forms.ModelForm):
title = forms.CharField(max_length=250, help_text="The name of the resource / blog.")
feed_url = forms.URLField(help_text="URL to the feed.")
public_url = forms.URLField(help_text="URL to main page of the resource (ie: blog homepage)")
feed_type = forms.ModelChoiceField(widget=forms.widgets.HiddenInput,
queryset=FeedType.objects.all())
title = forms.CharField(max_length=250,
help_text="title of the resource / blog.")
feed_url = forms.URLField(label='Feed URL',
help_text="link to the RSS/Atom feed. Please only use Django-specific feeds.")
public_url = forms.URLField(label='Public URL',
help_text="link to main page (i.e. blog homepage)")

class Meta:
model = Feed
exclude = ('is_defunct',)
exclude = ('is_defunct', 'feed_type')
10 changes: 7 additions & 3 deletions django_website/aggregator/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ def feed_list(request, feed_type_slug):
@login_required
def add_feed(request, feed_type_slug):
ft = get_object_or_404(FeedType, slug=feed_type_slug, can_self_add=True)
initial_data = {'feed_type': ft.id}
f = FeedModelForm(request.POST or None, initial=initial_data)
if not ft.can_self_add and not request.user.is_superuser:
return render_to_response('aggregator/denied.html',
context_instance=RequestContext(request))

instance = Feed(feed_type=ft)
f = FeedModelForm(request.POST or None, instance=instance)
if f.is_valid():
if f.save():
return HttpResponseRedirect(reverse('community-index'))
return render_to_response('aggregator/add_feed.html',
{'form':f},
{'form':f, 'feed_type': ft},
context_instance=RequestContext(request))
17 changes: 14 additions & 3 deletions django_website/templates/aggregator/add_feed.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@
{% block content %}
<h1>Community</h1>

<form method="POST" action="" id="add_feed_form">
{{ form.as_p }}
<input type="submit" name="submit" value="Add Feed" />
<h2 class="deck">Add a {{ feed_type }} feed:</h2>

<form method="POST" action="" id="add_feed_form" class="wide">
{% for field in form %}
<p>
<label id="{{ field.auto_id }}">{{ field.label }} - <span class="help">{{ field.help_text }}</label>
{% if field.errors %}
<p class="errors">{{ field.errors.as_text }}</p>
{% endif %}
{{ field }}
</p>
{% endfor %}
<p class="submit"><input type="submit" value="Add Feed"></p>
</form>

{% endblock %}
7 changes: 7 additions & 0 deletions django_website/templates/aggregator/denied.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "base_community.html" %}

{% block content %}
<h1>Community</h1>

<h2>Sorry, you can't do that.</h2>
{% endblock %}
2 changes: 1 addition & 1 deletion django_website/templates/aggregator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block content %}
<h1>Community</h1>
<h2 class="deck">This page, updated every hour, aggregates what's going on in the community.</h2>
<h2 class="deck">This page, updated regularly, aggregates what's going on in the community.</h2>

{% for feedtype in feedtype_list %}
<div id="{{ feedtype.slug }}" class="module {% cycle "first" "last" %}">
Expand Down
1 change: 0 additions & 1 deletion media/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ body#community h5 { margin-top: 5px; }
body#community #content-main .module { width: 350px; float: left; display: inline;}
body#community #content-main .first { margin-left: 20px; clear: left; }
body#community #content-main .last { margin-right: 5px; clear: right; }
body#community #add_feed_form label { display: block; width: 75px; float: left; }
body#community .hidden { display: none; }

/* LISTS */
Expand Down

0 comments on commit 39f9764

Please sign in to comment.