Skip to content

Commit

Permalink
remove old change attribute from consideration model
Browse files Browse the repository at this point in the history
  • Loading branch information
ashimali committed Aug 23, 2024
1 parent 3e38d5e commit dd06bf3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
4 changes: 2 additions & 2 deletions application/blueprints/planning_consideration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ def consideration(slug):
return redirect(url_for("planning_consideration.considerations"))

latest_change = None
if consideration.changes is not None and len(consideration.changes) > 0:
change_dates = [change["date"] for change in consideration.changes]
if consideration.change_log is not None and len(consideration.change_log) > 0:
change_dates = [change.created for change in consideration.change_log]
latest_change = max(change_dates)

notes = [note for note in consideration.notes if note.deleted_date is None]
Expand Down
2 changes: 0 additions & 2 deletions application/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ class Consideration(db.Model):
)

answers: Mapped[List["Answer"]] = relationship(back_populates="consideration")

changes: Mapped[Optional[list]] = mapped_column(MutableList.as_mutable(JSONB))
change_log: Mapped[List["ChangeLog"]] = relationship(
back_populates="consideration", order_by="asc(ChangeLog.created)"
)
Expand Down
2 changes: 1 addition & 1 deletion application/templates/consideration.html
Original file line number Diff line number Diff line change
Expand Up @@ -421,5 +421,5 @@ <h2 class="govuk-heading-l">{{ notes | length }} note{{ "" if notes|length == 1

{% block content_footer %}
<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible">
<span class="govuk-hint">{%- if latest_change %}<a href="{{url_for('planning_consideration.change_log', slug=consideration.slug) }}">Last updated: {{ latest_change }}</a>{% else %}No recent updates{% endif -%}</span>
<span class="govuk-hint">{%- if latest_change %}<a href="{{url_for('planning_consideration.change_log', slug=consideration.slug) }}">Last updated: {{ latest_change | date_time }}</a>{% else %}No recent updates{% endif -%}</span>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""drop changes field from consideration
Revision ID: 358969fe3651
Revises: 971e3a61cd16
Create Date: 2024-08-23 08:59:53.746853
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '358969fe3651'
down_revision = '971e3a61cd16'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('consideration', schema=None) as batch_op:
batch_op.drop_column('changes')

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('consideration', schema=None) as batch_op:
batch_op.add_column(sa.Column('changes', postgresql.JSONB(astext_type=sa.Text()), autoincrement=False, nullable=True))

# ### end Alembic commands ###

0 comments on commit dd06bf3

Please sign in to comment.