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

Enable/ disable revert using only a settings attribute #632

Merged
merged 12 commits into from
Apr 23, 2020
Merged

Enable/ disable revert using only a settings attribute #632

merged 12 commits into from
Apr 23, 2020

Conversation

erikvw
Copy link
Contributor

@erikvw erikvw commented Feb 20, 2020

Description

Some installations may not wish to allow users to revert original model instances via the history record. This PR adds a settings attribute SIMPLE_HISTORY_REVERT_DISABLED that if set to True removes the Revert button from the history form.

Motivation and Context

Makes it possible to globally disable the ability to revert a model instance via the historical record.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run the make format command to format my code
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have added my name and/or github handle to AUTHORS.rst
  • I have added my change to CHANGES.rst
  • All new and existing tests passed.

@codecov-io
Copy link

codecov-io commented Feb 20, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@8bcf4c4). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master    #632   +/-   ##
========================================
  Coverage          ?   97.7%           
========================================
  Files             ?      17           
  Lines             ?     914           
  Branches          ?     136           
========================================
  Hits              ?     893           
  Misses            ?       9           
  Partials          ?      12
Impacted Files Coverage Δ
simple_history/admin.py 98.38% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8bcf4c4...927086a. Read the comment docs.

@erikvw
Copy link
Contributor Author

erikvw commented Feb 20, 2020

@rossmechanic, I've separated this functionality out of the larger PR (#631) as I think you had requested some time ago. The next step, if this is accepted, is to complete #631. The new setting attribute introduced here will be needed for #631.

@erikvw erikvw changed the title Enable/ disable revert based on settings attribute Enable/ disable revert using only a settings attribute Feb 20, 2020
{% if not revert_disabled %}<input type="submit" value="{% trans 'Revert' %}" class="default" name="_save" {{ onclick_attrib }}/>{% endif %}
{% if change_history %}<input type="submit" value="{% trans 'Change History' %}" class="default" name="_change_history" {{ onclick_attrib }}/>{% endif %}
<a href="{{ history_url }}" class="closelink">{% trans 'Close' %}</a>
</div>

Choose a reason for hiding this comment

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

Missing a new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!

@@ -8,7 +8,7 @@
{% block content %}
<div id="content-main">

<p>{% blocktrans %}Choose a date from the list below to revert to a previous version of this object.{% endblocktrans %}</p>
{% if revert_disabled %}<p>{% blocktrans %}Choose a date from the list below to revert to a previous version of this object.{% endblocktrans %}</p>{% endif %}

Choose a reason for hiding this comment

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

Shouldn't this be not revert_disabled?

Copy link
Contributor Author

@erikvw erikvw Feb 25, 2020

Choose a reason for hiding this comment

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

ah, yes. you are correct. added the condition to tests as well. thanks!

gustavovaliati
gustavovaliati previously approved these changes Feb 25, 2020
Copy link
Collaborator

@rossmechanic rossmechanic left a comment

Choose a reason for hiding this comment

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

This looks good to me. I think I'd like to allow this on a model-level in the future, but this is great for now. Thanks @erikvw . Sorry I took awhile to get to this

@rossmechanic rossmechanic merged commit 184ecdd into jazzband:master Apr 23, 2020
@erikvw
Copy link
Contributor Author

erikvw commented Apr 27, 2020 via email

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