Skip to content
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

Fixed bug with data_finish. Now the finish date of a task needs to be greater than the start date. #173

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions taiga/projects/milestones/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def __repr__(self):
return "<Milestone {0}>".format(self.id)

def clean(self):

if self.estimated_start and self.estimated_start.year == datetime.MAXYEAR:
raise ValidationError(_("Invalid estimated start year, it must be less than 9999."))

# Don't allow draft entries to have a pub_date.
if self.estimated_start and self.estimated_finish and self.estimated_start > self.estimated_finish:
raise ValidationError(_('The estimated start must be previous to the estimated finish.'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,23 @@ def test_milestone_create(client, data):
assert results == [401, 403, 403, 451, 451]


def test_milestone_create_invalid_dates(client, data):
url = reverse('milestones-list')

user = data.project_owner
create_data = json.dumps({
"name": "test",
"estimated_start": "9999-12-10",
"estimated_finish": "9999-12-24",
"project": data.public_project.pk,
})

client.login(user)

response = client.post(url, create_data, content_type="application/json")
assert response.status_code == 400
assert response.data["__all__"][0] == "Invalid estimated start year, it must be less than 9999."

def test_milestone_patch(client, data):
public_url = reverse('milestones-detail', kwargs={"pk": data.public_milestone.pk})
private_url1 = reverse('milestones-detail', kwargs={"pk": data.private_milestone1.pk})
Expand Down
Loading