snowball-one / django-oscar-support

Customer services and ticketing plugin for Oscar
BSD 3-Clause "New" or "Revised" License
20 stars 10 forks source link

Generate slugs in data migration #8

Closed fmr closed 5 years ago

roadsideseb commented 10 years ago

Hmm, this seems like an overly complicated solution to simply generate unique slugs during this one data migration. Can you give some more details on why you did it this way instead of something simpler?

Maybe something like:

for idx, ticket_type in enumerate(ticket_type_qs):
    try:
        ticket_type.slug = slugify(ticket_type.name)
        ticket_type.save()
    except IntegrityError:
        ticket_type.slug = u"{}-{}".format(slugify(ticket_type.name), idx)
        ticket_type.save()
fmr commented 10 years ago

I don't think it's overly complicated. I thought of doing exactly that (plus or minus a few lines of code), but that functionality would only exist in that one migration. I added unique_slugify to utils.py so that it can be reused (i.e. for future data migrations). If you don't agree with this, then I can change it to what you have above.

roadsideseb commented 10 years ago

What are your thoughts on this @a-musing-moose?

SalahAdDin commented 5 years ago

what happened here?

fmr commented 5 years ago

It was a non-critical issue that had been open for 4 years, I thought it was time to close it, since none of us are actively working on it :)