Skip to content

Commit

Permalink
GraphNameExceedsLimit - #320 (#354)
Browse files Browse the repository at this point in the history
* #320 - UI Graph title limit too short - Fixes

* Update GraphSpace_Network_Model.md

I don't want to complicate the text too much. I think it is important to mention 256 characters though.

* Update error_codes.py

fix last commit deletion

Co-authored-by: Joseph D'Anna <35696537+jddanna@users.noreply.github.com>
  • Loading branch information
sanket0211 and jddanna committed Mar 15, 2021
1 parent 2ad3356 commit 265d0ee
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions applications/graphs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ def _add_graph(request, graph={}):

# Validate add graph API request
user_role = authorization.user_role(request)
graph_name = graph.get('name')
if len(graph_name)>256: # To check if the Graph Name is within the given range(i.e maximum 256 characters long)
raise BadRequest(request, error_code=ErrorCodes.Validation.GraphNameSize)
if user_role == authorization.UserRole.LOGGED_IN:
if get_request_user(request) != graph.get('owner_email', None):
raise BadRequest(request, error_code=ErrorCodes.Validation.CannotCreateGraphForOtherUser,
Expand Down
2 changes: 1 addition & 1 deletion docs/GraphSpace_Network_Model.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ The `Edge Object` describes an edge in the graph. An `Edge Object` typically con

- required:

- `name` – text – Name of the graph. Refer to [query semantics](/Searching_Graphs.html#query-semantics) section to find how `name` attribute is used for [searching graphs]().
- `name` – text – Name of the graph. Refer to [query semantics](/Searching_Graphs.html#query-semantics) section to find how `name` attribute is used for [searching graphs](). The maximum allowed length of the Graph Name is 256 character long.
- `tags` – list of strings – Used to categorize graphs. See the section on [organizing graphs using tags](/Organizing_Graphs_Using_Tags.html) for more information.
- `description` – text – May be HTML formatted string. May be link to image hosted elsewhere. May simly be a string which contains information such as a [legend or significance of the graph](/Viewing_Graphs.html#graph-information-tab). This information is displayed in the tab called [Graph Informtaion](/Viewing_Graphs.html#graph-information-tab).

Expand Down
2 changes: 1 addition & 1 deletion docs/Uploading_Graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The upload graph form has three input fields:

#### Graph Name

The name of the graph. [GraphSpace](http://graphspace.org) allows users to search graphs by their name. It is a required field.
The name of the graph. [GraphSpace](http://graphspace.org) allows users to search graphs by their name. It is a required field. The maximum allowed length of the Graph Name is 256 character long (The reason is to avoid very long graph names which can hamper the search page look and feel).

#### Network File

Expand Down
2 changes: 2 additions & 0 deletions graphspace/exceptions/error_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ class Validation(object):
1013, "Cannot create layout with owner email = `{0}`.")
LayoutNameAlreadyExists = (
1014, "Layout with name `{0}` already exists.")
GraphNameSize = (
1015, "Graph Name cannot be more than 256 characters long.")
2 changes: 1 addition & 1 deletion templates/upload_graph/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h1 class="text-center">Upload Graph</h1>
{% csrf_token %}
<div class="control-group">
<label for="GraphNameInput">Graph Name:</label>
<input id="GraphNameInput" class="form-control" maxlength="32" type="text"
<input id="GraphNameInput" class="form-control" maxlength="256" type="text"
name="name" autocomplete="off" placeholder="Required"/>
</div>

Expand Down

0 comments on commit 265d0ee

Please sign in to comment.