jingdoli / doli-beta

beta repo for doli
0 stars 0 forks source link

Http return code should be 400, not 500 if create a user with new user name but the email address has been taken before #3

Open BurningBird opened 11 years ago

BurningBird commented 11 years ago

Actual behavior:

create a new user with new user name, but give the email address as one that has been registered before, the request failed as expected, but return code is 500. then even if we modify the email address to be a unique one, the request will fail since the sever already added the user name.

Expected behavior:

  1. an error code of 400 should be returned if a user is trying to register with a duplicated/exiting email.
  2. the user should be able to sign up once they correct the email address
BurningBird commented 11 years ago

Traceback

Traceback (most recent call last):

File "/home/ubuntu/.virtualenvs/dolibeta/lib/python2.7/site-packages/tastypie/resources.py", line 217, in wrapper response = callback(request, _args, *_kwargs)

File "/home/ubuntu/.virtualenvs/dolibeta/lib/python2.7/site-packages/tastypie/resources.py", line 459, in dispatch_list return self.dispatch('list', request, **kwargs)

File "/home/ubuntu/.virtualenvs/dolibeta/lib/python2.7/site-packages/tastypie/resources.py", line 491, in dispatch response = method(request, **kwargs)

File "/home/ubuntu/.virtualenvs/dolibeta/lib/python2.7/site-packages/tastypie/resources.py", line 1357, in post_list updated_bundle = self.obj_create(bundle, **self.remove_api_resource_names(kwargs))

File "/home/doli-beta/doli-beta/doli/doli/api.py", line 132, in obj_create bundle.obj.save()

File "/home/ubuntu/.virtualenvs/dolibeta/lib/python2.7/site-packages/django/db/models/base.py", line 463, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update)

File "/home/ubuntu/.virtualenvs/dolibeta/lib/python2.7/site-packages/django/db/models/base.py", line 524, in save_base manager.using(using).filter(pk=pk_val).exists())):

File "/home/ubuntu/.virtualenvs/dolibeta/lib/python2.7/site-packages/django/db/models/query.py", line 565, in exists return self.query.has_results(using=self.db)

File "/home/ubuntu/.virtualenvs/dolibeta/lib/python2.7/site-packages/django/db/models/sql/query.py", line 441, in has_results return bool(compiler.execute_sql(SINGLE))

File "/home/ubuntu/.virtualenvs/dolibeta/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 818, in execute_sql cursor.execute(sql, params)

File "/home/ubuntu/.virtualenvs/dolibeta/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute return self.cursor.execute(query, args)

DatabaseError: current transaction is aborted, commands ignored until end of transaction block

<WSGIRequest path:/api/v1/newuser/, GET:<QueryDict: {u'username': [u'dolimobile'], u'api_key': [u'393efdd24a1cb2c7cfc12e26303de4a2c0fdc999']}>, POST:<QueryDict: {u'{"username":"test4", "password":"doli001", "email": "test3@aol.com"}': [u'']}>, COOKIES:{'csrftoken': 'qzJCJ5RuMHjKzDn7Wgf1mK08ZLqmiyMN', 'sessionid': '6f7c71449a7fa0c1a24c80c5b0c2265c'}, META:{'CONTENT_LENGTH': '68', 'CONTENT_TYPE': 'application/json', 'CSRF_COOKIE': 'qzJCJ5RuMHjKzDn7Wgf1mK08ZLqmiyMN', 'DJANGO_SETTINGS_MODULE': 'myproject.settings', 'DOCUMENT_ROOT': '/home/doli-beta/doli-beta/', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTPACCEPT': '/_', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8', 'HTTP_CACHE_CONTROL': 'no-cache', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'csrftoken=qzJCJ5RuMHjKzDn7Wgf1mK08ZLqmiyMN; sessionid=6f7c71449a7fa0c1a24c80c5b0c2265c', 'HTTP_HOST': 'ec2-54-226-141-39.compute-1.amazonaws.com', 'HTTP_ORIGIN': 'chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36', 'PATH_INFO': u'/api/v1/newuser/', 'PATH_TRANSLATED': '/home/doli-beta/doli-beta/doli/apache/django.wsgi/api/v1/newuser/', 'QUERY_STRING': 'username=dolimobile&api_key=393efdd24a1cb2c7cfc12e26303de4a2c0fdc999', 'REMOTE_ADDR': '76.102.101.47', 'REMOTE_PORT': '58037', 'REQUEST_METHOD': 'POST', 'REQUEST_URI': '/api/v1/newuser/?username=dolimobile&api_key=393efdd24a1cb2c7cfc12e26303de4a2c0fdc999', 'SCRIPT_FILENAME': '/home/doli-beta/doli-beta/doli/apache/django.wsgi', 'SCRIPT_NAME': u'', 'SERVER_ADDR': '10.179.30.84', 'SERVER_ADMIN': '[no address given]', 'SERVER_NAME': 'ec2-54-226-141-39.compute-1.amazonaws.com', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SIGNATURE': '

Apache/2.2.22 (Ubuntu) Server at ec2-54-226-141-39.compute-1.amazonaws.com Port 80
\n', 'SERVER_SOFTWARE': 'Apache/2.2.22 (Ubuntu)', 'mod_wsgi.application_group': 'ec2-54-221-16-92.compute-1.amazonaws.com|', 'mod_wsgi.callable_object': 'application', 'mod_wsgi.handler_script': '', 'mod_wsgi.input_chunked': '0', 'mod_wsgi.listener_host': '', 'mod_wsgi.listener_port': '80', 'mod_wsgi.process_group': '', 'mod_wsgi.request_handler': 'wsgi-script', 'mod_wsgi.script_reloading': '1', 'mod_wsgi.version': (3, 3), 'wsgi.errors': <mod_wsgi.Log object at 0x7fcfaea763f0>, 'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7fcfaea7a8a0>, 'wsgi.input': <mod_wsgi.Input object at 0x7fcfaea763b0>, 'wsgi.multiprocess': True, 'wsgi.multithread': False, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 1)}>