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

Fixes GH-201 - Assets do not move to "Active Assets" section when toggled "On" #202

Merged
merged 7 commits into from
May 17, 2014

Conversation

richard-to
Copy link
Contributor

The View code was checking the Asset model's is_active property. Unfortunately that property does not exist. The closest property is is_enabled. I used is_enabled since it looks like the backend expects that property.

@Kentzo
Copy link

Kentzo commented May 12, 2014

Hi @richard-to. Thank you for the PR!

Active means that it's both enabled and current time lies within its start date and end date. See https://github.com/wireload/screenly-ose/blob/master/assets_helper.py#L29-L31

I think proper solution would be to calculate and set is_active the same way we to it in Python.

@richard-to
Copy link
Contributor Author

Thanks for the clarification. I'll update the pull request tomorrow. Thanks.

@vpetersson
Copy link
Contributor

Thanks @richard-to and @Kentzo.

Add is_active, backup, rollback methods to Asset model
Conflicts:
	static/js/screenly-ose.coffee
	static/js/screenly-ose.js
@richard-to
Copy link
Contributor Author

Ok, I added the correct logic for active assets.

I had forgotten to create a new branch originally, so I also have a few changes for GH-199 too. I moved the logic to the model instead.

Also I updated the Jasmine unit tests so that they at least work.

I added unit tests for this pull request and the other one.

at = now()
start_date = new Date(@get('start_date'));
end_date = new Date(@get('end_date'));
return start_date < at and end_date > at
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be an inclusive comparison, e.g. start_date <= at and end_date => at?

By the way, coffeescript supports Python like chained comparisons. So you can do this: start_date <= at <= end_date for simplicity.

@aljungberg
Copy link
Collaborator

The tests look nice.

@richard-to
Copy link
Contributor Author

@aljungberg: For the dates, I agree that it makes sense for start and end to be inclusive.

I was going by the backend code that @Kentzo linked here: https://github.com/wireload/screenly-ose/blob/master/assets_helper.py#L29-L31

@aljungberg
Copy link
Collaborator

Yes feels like the backend code should do the same. And it can also be updated to use a chained comparison for that matter.

@richard-to
Copy link
Contributor Author

Ok, I updated the frontend/backend to be inclusive now. The chained comparison is definitely easier to read.

vpetersson added a commit that referenced this pull request May 17, 2014
Fixes GH-201 - Assets do not move to "Active Assets" section when toggled "On"
@vpetersson vpetersson merged commit 8e39ae9 into Screenly:master May 17, 2014
@vpetersson
Copy link
Contributor

Awesome. Thanks @richard-to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants