mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-05 12:47:29 +01:00
Add dependency support to Edit Requests
This commit is contained in:
parent
9d91d337d5
commit
079775f5f6
16
README.md
16
README.md
@ -40,3 +40,19 @@ Then run the server:
|
|||||||
./rundebug.py
|
./rundebug.py
|
||||||
|
|
||||||
Then view in your web browser: http://localhost:5000/
|
Then view in your web browser: http://localhost:5000/
|
||||||
|
|
||||||
|
## How-tos
|
||||||
|
|
||||||
|
### Create migration
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# if sqlite
|
||||||
|
python setup.py -t
|
||||||
|
rm db.sqlite && python setup.py -t && FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db stamp head
|
||||||
|
|
||||||
|
# Create migration
|
||||||
|
FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db migrate
|
||||||
|
|
||||||
|
# Run migration
|
||||||
|
FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db migrate
|
||||||
|
```
|
||||||
|
@ -225,6 +225,9 @@ class PackagePropertyKey(enum.Enum):
|
|||||||
def convert(self, value):
|
def convert(self, value):
|
||||||
if self == PackagePropertyKey.tags:
|
if self == PackagePropertyKey.tags:
|
||||||
return ",".join([t.title for t in value])
|
return ",".join([t.title for t in value])
|
||||||
|
elif self == PackagePropertyKey.harddeps or self == PackagePropertyKey.softdeps:
|
||||||
|
return ",".join([t.author.username + "/" + t.name for t in value])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return str(value)
|
return str(value)
|
||||||
|
|
||||||
@ -531,6 +534,43 @@ class EditRequestChange(db.Model):
|
|||||||
for tagTitle in self.newValue.split(","):
|
for tagTitle in self.newValue.split(","):
|
||||||
tag = Tag.query.filter_by(title=tagTitle.strip()).first()
|
tag = Tag.query.filter_by(title=tagTitle.strip()).first()
|
||||||
package.tags.append(tag)
|
package.tags.append(tag)
|
||||||
|
|
||||||
|
elif self.key == PackagePropertyKey.harddeps:
|
||||||
|
package.harddeps.clear()
|
||||||
|
for pair in self.newValue.split(","):
|
||||||
|
key, value = pair.split("/")
|
||||||
|
if key is None or value is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
user = User.query.filter_by(username=key).first()
|
||||||
|
if user is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
dep = Package.query.filter_by(author=user, name=value).first()
|
||||||
|
if dep is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
package.harddeps.append(dep)
|
||||||
|
|
||||||
|
elif self.key == PackagePropertyKey.softdeps:
|
||||||
|
package.softdeps.clear()
|
||||||
|
for pair in self.newValue.split(","):
|
||||||
|
key, value = pair.split("/")
|
||||||
|
if key is None or value is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
user = User.query.filter_by(username=key).first()
|
||||||
|
if user is None:
|
||||||
|
raise Exception("No such user!")
|
||||||
|
continue
|
||||||
|
|
||||||
|
dep = Package.query.filter_by(author=user, name=value).first()
|
||||||
|
if dep is None:
|
||||||
|
raise Exception("No such package!")
|
||||||
|
continue
|
||||||
|
|
||||||
|
package.softdeps.append(dep)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
setattr(package, self.key.name, self.newValue)
|
setattr(package, self.key.name, self.newValue)
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
{{ render_field(form.type) }}
|
{{ render_field(form.type) }}
|
||||||
{{ render_field(form.license) }}
|
{{ render_field(form.license) }}
|
||||||
{{ render_multiselect_field(form.tags) }}
|
{{ render_multiselect_field(form.tags) }}
|
||||||
|
{{ render_multiselect_field(form.harddeps) }}
|
||||||
|
{{ render_multiselect_field(form.softdeps) }}
|
||||||
{{ render_field(form.repo) }}
|
{{ render_field(form.repo) }}
|
||||||
{{ render_field(form.website) }}
|
{{ render_field(form.website) }}
|
||||||
{{ render_field(form.issueTracker) }}
|
{{ render_field(form.issueTracker) }}
|
||||||
|
Loading…
Reference in New Issue
Block a user