Comments (4)
@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.
from refinery-platform.
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.
@hackdna Thanks for looking into this
from refinery-platform.
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)
- Fix Cancel button functionality on FB Details tab
- Update jquery-fileupload library
- FIle Browser - Fix Padding Input Group List
- Enable compliance with WCAG 2.1 Level AA
- Update UI Dependencies to support ES6
- Analysis import fails due to celery SoftTimeLimitExceeded HOT 6
- data_set_manager has test with non-determinstic behavior
- Update mockcache HOT 4
- Remove djangular
- Pass in Context for ToolSerializer HOT 3
- DataSet file_count off with Solr Total node_count
- Add h5 files to the FileType object
- Update TextFields that hold JSON to JSONFields
- 500 Error UserDoesNotExist HOT 1
- Bam File IGV Not Working HOT 3
- Landing Page Attribute Search Bug
- File-Browser: Select All Bug
- Refactor Celery and Analysis Handling
- Upgrade to Python 3.6+
- Celery Chain Does Not Fail HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from refinery-platform.