diff --git a/app/models.py b/app/models.py index c97bdd90..02ae8876 100644 --- a/app/models.py +++ b/app/models.py @@ -251,6 +251,7 @@ class EditRequest(db.Model): title = db.Column(db.String(100), nullable=False) desc = db.Column(db.String(1000), nullable=True) + status = db.Column(db.Integer, nullable=False, default=0) changes = db.relationship("EditRequestChange", backref="request", lazy="dynamic") @@ -262,6 +263,20 @@ class EditRequest(db.Model): name=self.package.name, id=self.id) + def getApproveURL(self): + return url_for("approve_editrequest_page", + ptype=self.package.type.toName(), + author=self.package.author.username, + name=self.package.name, + id=self.id) + + def getRejectURL(self): + return url_for("reject_editrequest_page", + ptype=self.package.type.toName(), + author=self.package.author.username, + name=self.package.name, + id=self.id) + def applyAll(self, package): for change in self.changes: change.apply(package) @@ -275,12 +290,11 @@ class EditRequestChange(db.Model): key = db.Column(db.Enum(PackagePropertyKey), nullable=False) # TODO: make diff instead - oldValue = db.Column(db.Text, nullable=False) - newValue = db.Column(db.Text, nullable=False) + oldValue = db.Column(db.Text, nullable=True) + newValue = db.Column(db.Text, nullable=True) def apply(self, package): - prop = PackagePropertyKey[self.key] - + setattr(package, self.key.name, self.newValue) # Setup Flask-User db_adapter = SQLAlchemyAdapter(db, User) # Register the User model diff --git a/app/static/style.css b/app/static/style.css index 551cc740..57d51993 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -147,6 +147,11 @@ a:hover { border: 1px solid #c96; } +.alert-success { + background: #161; + border: 1px solid #393; +} + /* Nav */ nav, main, #alerts { diff --git a/app/templates/packages/editrequest_view.html b/app/templates/packages/editrequest_view.html index b7abbbe2..22b60ae2 100644 --- a/app/templates/packages/editrequest_view.html +++ b/app/templates/packages/editrequest_view.html @@ -16,6 +16,21 @@ No description given {% endif %}

+ {% if request.status == 1 %} +
+ This edit request was merged. +
+ {% elif request.status == 2 %} +
+ This edit request was rejected. +
+ {% elif package.checkPerm(current_user, "APPROVE_CHANGES") %} +
+ To resolve this request, either + Approve and Apply or + Reject it. +
+ {% endif %} diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html index 9ed7defd..2ed3a321 100644 --- a/app/templates/packages/view.html +++ b/app/templates/packages/view.html @@ -87,11 +87,11 @@ {% endfor %} - {% if current_user.is_authenticated or package.requests %} + {% if current_user.is_authenticated or requests %}

Edit Requests