Skip to content

Setting for unique constraint on project titles #608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions coldfront/config/core.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
# Enable Project Review
#------------------------------------------------------------------------------
PROJECT_ENABLE_PROJECT_REVIEW = ENV.bool('PROJECT_ENABLE_PROJECT_REVIEW', default=True)
PROJECT_TITLE_UNIQUE = ENV.bool('PROJECT_TITLE_UNIQUE', default=False)

#------------------------------------------------------------------------------
# Allocation related
3 changes: 2 additions & 1 deletion coldfront/core/project/models.py
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
from coldfront.core.utils.common import import_from_settings

PROJECT_ENABLE_PROJECT_REVIEW = import_from_settings('PROJECT_ENABLE_PROJECT_REVIEW', False)
PROJECT_TITLE_UNIQUE = import_from_settings('PROJECT_TITLE_UNIQUE', False)

class ProjectPermission(Enum):
""" A project permission stores the user, manager, pi, and update fields of a project. """
@@ -76,7 +77,7 @@ def get_by_natural_key(self, title, pi_username):
We do not have information about your research. Please provide a detailed description of your work and update your field of science. Thank you!
'''

title = models.CharField(max_length=255,)
title = models.CharField(max_length=255, unique=PROJECT_TITLE_UNIQUE,)
pi = models.ForeignKey(User, on_delete=models.CASCADE,)
description = models.TextField(
default=DEFAULT_DESCRIPTION,
1 change: 1 addition & 0 deletions docs/pages/config.md
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@ The following settings are ColdFront specific settings related to the core appli
| CENTER_PROJECT_RENEWAL_HELP_URL | The URL of the article describing project renewals |
| CENTER_BASE_URL | The base URL of your center. |
| PROJECT_ENABLE_PROJECT_REVIEW | Enable or disable project reviews. Default True|
| PROJECT_TITLE_UNIQUE | Enable or disable unique constraint on project titles. Default False |
| ALLOCATION_ENABLE_ALLOCATION_RENEWAL | Enable or disable allocation renewals. Default True |
| ALLOCATION_DEFAULT_ALLOCATION_LENGTH | Default number of days an allocation is active for. Default 365 |
| ALLOCATION_ENABLE_CHANGE_REQUESTS_BY_DEFAULT | Enable or disable allocation change requests. Default True |