Example #1
0
 def _copyFeedToForm(self, feed):
     """Copy relevant fields from Feed to FeedForm"""
     ff = FeedForm()
     for field in ff.all_fields():
         if hasattr(feed, field.name):
             setattr(ff, field.name, getattr(feed, field.name))
         elif field.name == "websafeKey":
             setattr(ff, field.name, feed.key.urlsafe())
     ff.check_initialized()
     return ff
Example #2
0
def add(request):
    if request.method == 'POST':
        form = FeedForm(request.POST)
        if form.is_valid():
            feed = form.save(commit=False)
            feed.initialize()
            return render_to_response('rerun/feed.html', {'feed': feed})
    else:
        form = FeedForm()
    return render_to_response('rerun/add.html', {'form': form}, context_instance=RequestContext(request))
Example #3
0
def new_feed(request):
    '''
    Create a new feed
    '''
    if request.method == 'POST': # If the form has been submitted...
        form = FeedForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            form.save()
            return HttpResponseRedirect(reverse(show_feeds)) # Redirect after POST
        else:
            form = FeedForm() # An unbound form

    form = FeedForm()
    context = {'form': form}
    return render_to_response('rss/new_feed.html', context, RequestContext(request))
Example #4
0
def edit_feed(request, feed_id):
    '''
    View used for editing and manually updating feeds
    '''
    if request.method == 'POST': # If the form has been submitted...
        form = FeedForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            f = Feed.objects.get(pk=feed_id)
            feed = FeedForm(request.POST, instance=f)
            feed.save()
            return HttpResponseRedirect(reverse(show_feeds)) # Redirect after POST

    try:
        form = FeedForm(instance=Feed.objects.get(pk=feed_id))
    except ObjectDoesNotExist:
        form = FeedForm()

    context = {'form': form}
    return render_to_response('rss/edit_feed.html', context, RequestContext(request))