GithubHelp home page GithubHelp logo

Comments (4)

scottx611x avatar scottx611x commented on July 3, 2024

@ngehlenborg Is this fix as simple as:

- slug = models.CharField(max_length=250, blank=True, null=True)
+ slug = models.CharField(unique=True, max_length=250, blank=True, null=True)

Or should I be delving deeper into this?

It seems like the behavior that you want has been implemented, shown below.

screen shot 2015-09-22 at 2 24 56 pm

from refinery-platform.

hackdna avatar hackdna commented on July 3, 2024

Yes, the solution is more involved that just adding a constraint to the model field. We need to handle duplicate slug error whenever a data set is saved. See this traceback for more details:

Traceback (most recent call last):

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view
    return view_func(request, *args, **kwargs)

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/views/generic/base.py", line 86, in dispatch
    return handler(request, *args, **kwargs)

  File "/srv/scc/apps/refinery-platform/refinery/data_set_manager/views.py", line 261, in post
    is_public=request.POST.get('is_public', False))

  File "/srv/scc/apps/refinery-platform/refinery/data_set_manager/single_file_column_parser.py", line 349, in process_metadata_table
    dataset_name=title, slug=slug, public=is_public)

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/celery/app/task/__init__.py", line 247, in __call__
    return self.run(*args, **kwargs)

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/celery/app/__init__.py", line 175, in run
    return fun(*args, **kwargs)

  File "/srv/scc/apps/refinery-platform/refinery/data_set_manager/tasks.py", line 364, in create_dataset
    dataset.save()

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/db/models/base.py", line 546, in save
    force_update=force_update, update_fields=update_fields)

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/db/models/base.py", line 626, in save_base
    rows = manager.using(using).filter(pk=pk_val)._update(values)

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/db/models/query.py", line 605, in _update
    return query.get_compiler(self.db).execute_sql(None)

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1014, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
    cursor.execute(sql, params)

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 56, in execute
    six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])

  File "/srv/scc/virtualenvs/refinery-platform/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 54, in execute
    return self.cursor.execute(query, args)

IntegrityError: duplicate key value violates unique constraint "core_dataset_slug_uniq"

from refinery-platform.

scottx611x avatar scottx611x commented on July 3, 2024

@hackdna Thanks for looking into this

from refinery-platform.

scottx611x avatar scottx611x commented on July 3, 2024

Functionality after commit: 0f9f020

>>> DataSet(slug="COOL_SLUG").save()
>>> DataSet(slug="COOL_SLUG").save()
2015-11-17 15:30:26 ERROR    core.models:196 save() - DataSet with slug: COOL_SLUG already exists!

from refinery-platform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.