Skip to content

Commit

Permalink
ensure registration don't are accidentally created with 'Untitled' ti…
Browse files Browse the repository at this point in the history
…tles
  • Loading branch information
John Tordoff committed Sep 11, 2023
1 parent a3e0a0b commit 8d6eeda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion osf/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,10 @@ def copy_editable_fields(self, resource, auth=None, alternative_resource=None, i
but the alternative_resource will be a Node. DraftRegistration fields will trump Node fields.
TODO, add optional logging parameter
"""
self.set_editable_attribute('title', resource, alternative_resource)
from osf.models.draft_node import DraftNode
if not isinstance(resource, DraftNode): # Force the user to add there own title.
self.set_editable_attribute('title', resource, alternative_resource)

self.set_editable_attribute('description', resource, alternative_resource)
self.set_editable_attribute('category', resource, alternative_resource)
self.set_editable_attribute('node_license', resource, alternative_resource)
Expand Down
2 changes: 1 addition & 1 deletion osf/models/registrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ def create_from_node(cls, user, schema, node=None, data=None, provider=None):

if not node:
# If no node provided, a DraftNode is created for you
node = DraftNode.objects.create(creator=user, title='Untitled')
node = DraftNode.objects.create(creator=user, title=settings.DEFAULT_DRAFT_NODE_TITLE)

if not (isinstance(node, Node) or isinstance(node, DraftNode)):
raise DraftRegistrationStateError()
Expand Down
1 change: 1 addition & 0 deletions website/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -2129,3 +2129,4 @@ def from_node_usage(cls, usage_bytes, private_limit=None, public_limit=None):
PREPRINT_METRICS_START_DATE = datetime.datetime(2019, 1, 1)

WAFFLE_VALUES_YAML = 'osf/features.yaml'
DEFAULT_DRAFT_NODE_TITLE = 'Untitled'

0 comments on commit 8d6eeda

Please sign in to comment.