Ticket #418: trac_418_slug_generation.patch

File trac_418_slug_generation.patch, 3.2 KB (added by Emily O'Leary, 11 years ago)

Patch to fix #418

  • mediagoblin/processing/task.py

    From a45dee02e419d2ed1b9b3316d24ccea43a2c5571 Mon Sep 17 00:00:00 2001
    From: Emily O'Leary <lotusecho@ThinkLotus>
    Date: Sun, 24 Mar 2013 23:43:45 -0400
    Subject: [PATCH 1/2] Moved where the slug was being generated to the end of
     the task so that if it fails before then no slug is
     created for it.
    
    ---
     mediagoblin/processing/task.py |    2 ++
     mediagoblin/submit/views.py    |    3 ---
     2 files changed, 2 insertions(+), 3 deletions(-)
    
    diff --git a/mediagoblin/processing/task.py b/mediagoblin/processing/task.py
    index 9af192e..2a8b0bc 100644
    a b class ProcessMedia(task.Task):  
    9494            # We set the state to processed and save the entry here so there's
    9595            # no need to save at the end of the processing stage, probably ;)
    9696            entry.state = u'processed'
     97            #Generate the slug here rather than earlier when it could have failed.
     98            entry.generate_slug()
    9799            entry.save()
    98100
    99101            # Notify the PuSH servers as async task
  • mediagoblin/submit/views.py

    diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py
    index 3f9d5b2..b2629bb 100644
    a b def submit_start(request):  
    7878                entry.tags = convert_to_tag_list_of_dicts(
    7979                    submit_form.tags.data)
    8080
    81                 # Generate a slug from the title
    82                 entry.generate_slug()
    83 
    8481                queue_file = prepare_queue_task(request.app, entry, filename)
    8582
    8683                with queue_file:
  • mediagoblin/plugins/api/views.py

    -- 
    1.7.10.4
    
    
    From 8b25f7139bdd8180947fe36dba0cebf80b94c74f Mon Sep 17 00:00:00 2001
    From: Emily O'Leary <Emma.C.Echo@gmail.com>
    Date: Tue, 6 Aug 2013 16:31:30 -0400
    Subject: [PATCH 2/2] Rebased with current master. Replaced tabs with four
     spaces in task.py. Removed generate_slug() from
     plugins/api/views.py.
    
    ---
     mediagoblin/plugins/api/views.py |    2 --
     mediagoblin/processing/task.py   |    4 ++--
     2 files changed, 2 insertions(+), 4 deletions(-)
    
    diff --git a/mediagoblin/plugins/api/views.py b/mediagoblin/plugins/api/views.py
    index 9159fe6..0e8735b 100644
    a b def post_entry(request):  
    6161    entry.description = unicode(request.form.get('description'))
    6262    entry.license = unicode(request.form.get('license', ''))
    6363
    64     entry.generate_slug()
    65 
    6664    # queue appropriately
    6765    queue_file = prepare_queue_task(request.app, entry, media_file.filename)
    6866
  • mediagoblin/processing/task.py

    diff --git a/mediagoblin/processing/task.py b/mediagoblin/processing/task.py
    index 2a8b0bc..ba2323b 100644
    a b class ProcessMedia(task.Task):  
    9494            # We set the state to processed and save the entry here so there's
    9595            # no need to save at the end of the processing stage, probably ;)
    9696            entry.state = u'processed'
    97             #Generate the slug here rather than earlier when it could have failed.
    98             entry.generate_slug()
     97            #Generate the slug here rather than earlier when it could have failed.
     98            entry.generate_slug()
    9999            entry.save()
    100100
    101101            # Notify the PuSH servers as async task