Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Claned up the style/display of the aggregator add form, and also adde…

…d a bit

better permission checking.
  • Loading branch information...
commit 39f976459e152ceb0345f3414b1a31f402d23f7d 1 parent 68acbaa
@jacobian jacobian authored
View
14 django_website/aggregator/forms.py
@@ -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')
View
10 django_website/aggregator/views.py
@@ -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))
View
17 django_website/templates/aggregator/add_feed.html
@@ -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 %}
View
7 django_website/templates/aggregator/denied.html
@@ -0,0 +1,7 @@
+{% extends "base_community.html" %}
+
+{% block content %}
+<h1>Community</h1>
+
+<h2>Sorry, you can't do that.</h2>
+{% endblock %}
View
2  django_website/templates/aggregator/index.html
@@ -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" %}">
View
1  media/css/base.css
@@ -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 */
Please sign in to comment.
Something went wrong with that request. Please try again.