Skip to content

Commit

Permalink
Revert "Merge pull request #3982 from codalab/fix/3961"
Browse files Browse the repository at this point in the history
This reverts commit a4ec95c, reversing
changes made to 285883c.
  • Loading branch information
jzwang43 committed Feb 9, 2022
1 parent be89dd7 commit 19c2f74
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
4 changes: 2 additions & 2 deletions codalab/rest/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

class CompatibleInteger(fields.Integer):
def serialize(self, attr, obj, accessor=None):
"""Overrides change done from 2.10.2->2.10.3 in https://github.com/marshmallow-code/marshmallow/commit/d81cab413e231ec40123020f110a8c0af22163ed."""
"""Overrides change done from 2.10.2->2.10.3 in https://github.com/marshmallow-code/marshmallow/commit/d81cab413e231ec40123020f110a8c0af22163ed.
"""
ret = Field.serialize(self, attr, obj, accessor=accessor)
return self._to_string(ret) if (self.as_string and ret is not None) else ret

Expand Down Expand Up @@ -306,7 +307,6 @@ class UserSchema(Schema):
url = fields.Url(allow_none=True)
date_joined = fields.LocalDateTime("%c")
avatar_id = fields.String(allow_none=True)
has_access = fields.Bool()

class Meta:
type_ = 'users'
Expand Down
4 changes: 1 addition & 3 deletions docs/REST-API-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ Name | Type
`url` | Url
`date_joined` | LocalDateTime
`avatar_id` | String
`has_access` | Boolean
`email` | String
`notifications` | Integer
`time_quota` | Integer
Expand All @@ -146,6 +145,7 @@ Name | Type
`disk_used` | Integer
`last_login` | LocalDateTime
`is_verified` | Boolean
`has_access` | Boolean

## users

Expand All @@ -160,7 +160,6 @@ Name | Type
`url` | Url
`date_joined` | LocalDateTime
`avatar_id` | String
`has_access` | Boolean
`email` | String
`notifications` | Integer
`time_quota` | Integer
Expand Down Expand Up @@ -294,7 +293,6 @@ Name | Type
`url` | Url
`date_joined` | LocalDateTime
`avatar_id` | String
`has_access` | Boolean

## worksheet-items

Expand Down
9 changes: 1 addition & 8 deletions frontend/src/components/Dashboard/NewDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { default as MainPanel } from './MainPanel';
import $ from 'jquery';
import { withRouter } from 'react-router';
import { defaultErrorHandler, getUser, getUsers } from '../../util/apiWrapper';
import ErrorMessage from '../worksheets/ErrorMessage';

/**
* This route page displays the new Dashboard, which is the landing page for all the users.
Expand Down Expand Up @@ -68,13 +67,7 @@ class NewDashboard extends React.Component<{

/** Renderer. */
render() {
if (this.state.userInfo && !this.state.userInfo.has_access) {
return (
<ErrorMessage
message={'No access to this server, please contact the administrators.'}
/>
);
} else if (this.state.userInfo) {
if (this.state.userInfo) {
return (
<div>
<Grid container spacing={30}>
Expand Down
18 changes: 8 additions & 10 deletions tests/unit/rest/user_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class UserTest(BaseTestCase):
def test_user_unauthenticated(self):
os.environ["CODALAB_TEST_USER"] = ""
response = self.app.get("/rest/user")
response = self.app.get('/rest/user')
self.assertEqual(response.status_int, 302)
self.assertEqual(
response.headers["Location"],
Expand All @@ -14,7 +14,7 @@ def test_user_unauthenticated(self):

def test_user_authenticated(self):
os.environ["CODALAB_TEST_USER"] = "codalab"
response = self.app.get("/rest/user")
response = self.app.get('/rest/user')
self.assertEqual(response.status_int, 200)
data = response.json["data"]
# These variables can change due to other tests.
Expand All @@ -24,23 +24,21 @@ def test_user_authenticated(self):
del data["attributes"]["last_login"]
del data["attributes"]["disk_quota"]
del data["attributes"]["time_quota"]

self.assertEqual(
data,
{
"type": "users",
"attributes": {
"last_name": "",
"first_name": "",
"affiliation": "",
"email": "",
"has_access": True,
"first_name": "",
"parallel_run_quota": 100,
"last_name": "",
"url": None,
"notifications": 2,
"user_name": "codalab",
"url": None,
"parallel_run_quota": 100,
"affiliation": "",
"avatar_id": None,
"is_root_user": True,
'is_root_user': True,
},
"id": "0",
},
Expand Down

0 comments on commit 19c2f74

Please sign in to comment.