Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99548ea65f | ||
|
|
325ee02b49 | ||
|
|
a60786d32c | ||
|
|
2976afd5d1 | ||
|
|
744c52ba18 | ||
|
|
c31c1fd92a |
@@ -18,7 +18,7 @@ from flask import Blueprint
|
|||||||
|
|
||||||
bp = Blueprint("github", __name__)
|
bp = Blueprint("github", __name__)
|
||||||
|
|
||||||
from flask import redirect, url_for, request, flash, abort, render_template, jsonify
|
from flask import redirect, url_for, request, flash, abort, render_template, jsonify, current_app
|
||||||
from flask_user import current_user, login_required
|
from flask_user import current_user, login_required
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from flask_github import GitHub
|
from flask_github import GitHub
|
||||||
@@ -35,6 +35,12 @@ from wtforms import SelectField, SubmitField
|
|||||||
def start():
|
def start():
|
||||||
return github.authorize("", redirect_uri=abs_url_for("github.callback"))
|
return github.authorize("", redirect_uri=abs_url_for("github.callback"))
|
||||||
|
|
||||||
|
@bp.route("/github/view/")
|
||||||
|
def view_permissions():
|
||||||
|
url = "https://github.com/settings/connections/applications/" + \
|
||||||
|
current_app.config["GITHUB_CLIENT_ID"]
|
||||||
|
return redirect(url)
|
||||||
|
|
||||||
@bp.route("/github/callback/")
|
@bp.route("/github/callback/")
|
||||||
@github.authorized_handler
|
@github.authorized_handler
|
||||||
def callback(oauth_token):
|
def callback(oauth_token):
|
||||||
|
|||||||
@@ -164,12 +164,7 @@ def download(package):
|
|||||||
flash("No download available.", "danger")
|
flash("No download available.", "danger")
|
||||||
return redirect(package.getDetailsURL())
|
return redirect(package.getDetailsURL())
|
||||||
else:
|
else:
|
||||||
PackageRelease.query.filter_by(id=release.id).update({
|
return redirect(release.getDownloadURL(), code=302)
|
||||||
"downloads": PackageRelease.downloads + 1
|
|
||||||
})
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
return redirect(release.url, code=302)
|
|
||||||
|
|
||||||
|
|
||||||
class PackageForm(FlaskForm):
|
class PackageForm(FlaskForm):
|
||||||
@@ -178,8 +173,8 @@ class PackageForm(FlaskForm):
|
|||||||
short_desc = StringField("Short Description (Plaintext)", [InputRequired(), Length(1,200)])
|
short_desc = StringField("Short Description (Plaintext)", [InputRequired(), Length(1,200)])
|
||||||
desc = TextAreaField("Long Description (Markdown)", [Optional(), Length(0,10000)])
|
desc = TextAreaField("Long Description (Markdown)", [Optional(), Length(0,10000)])
|
||||||
type = SelectField("Type", [InputRequired()], choices=PackageType.choices(), coerce=PackageType.coerce, default=PackageType.MOD)
|
type = SelectField("Type", [InputRequired()], choices=PackageType.choices(), coerce=PackageType.coerce, default=PackageType.MOD)
|
||||||
license = QuerySelectField("License", [InputRequired()], query_factory=lambda: License.query.order_by(db.asc(License.name)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
license = QuerySelectField("License", [DataRequired()], allow_blank=True, query_factory=lambda: License.query.order_by(db.asc(License.name)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
||||||
media_license = QuerySelectField("Media License", [InputRequired()], query_factory=lambda: License.query.order_by(db.asc(License.name)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
media_license = QuerySelectField("Media License", [DataRequired()], allow_blank=True, query_factory=lambda: License.query.order_by(db.asc(License.name)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
||||||
provides_str = StringField("Provides (mods included in package)", [Optional()])
|
provides_str = StringField("Provides (mods included in package)", [Optional()])
|
||||||
tags = QuerySelectMultipleField('Tags', query_factory=lambda: Tag.query.order_by(db.asc(Tag.name)), get_pk=lambda a: a.id, get_label=lambda a: a.title)
|
tags = QuerySelectMultipleField('Tags', query_factory=lambda: Tag.query.order_by(db.asc(Tag.name)), get_pk=lambda a: a.id, get_label=lambda a: a.title)
|
||||||
harddep_str = StringField("Hard Dependencies", [Optional()])
|
harddep_str = StringField("Hard Dependencies", [Optional()])
|
||||||
@@ -227,6 +222,8 @@ def create_edit(author=None, name=None):
|
|||||||
form.title.data = request.args.get("title")
|
form.title.data = request.args.get("title")
|
||||||
form.repo.data = request.args.get("repo")
|
form.repo.data = request.args.get("repo")
|
||||||
form.forums.data = request.args.get("forums")
|
form.forums.data = request.args.get("forums")
|
||||||
|
form.license.data = None
|
||||||
|
form.media_license.data = None
|
||||||
else:
|
else:
|
||||||
form.harddep_str.data = ",".join([str(x) for x in package.getSortedHardDependencies() ])
|
form.harddep_str.data = ",".join([str(x) for x in package.getSortedHardDependencies() ])
|
||||||
form.softdep_str.data = ",".join([str(x) for x in package.getSortedOptionalDependencies() ])
|
form.softdep_str.data = ",".join([str(x) for x in package.getSortedOptionalDependencies() ])
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ def profile(username):
|
|||||||
# Copy form fields to user_profile fields
|
# Copy form fields to user_profile fields
|
||||||
if user.checkPerm(current_user, Permission.CHANGE_DNAME):
|
if user.checkPerm(current_user, Permission.CHANGE_DNAME):
|
||||||
user.display_name = form["display_name"].data
|
user.display_name = form["display_name"].data
|
||||||
|
|
||||||
|
if user.checkPerm(current_user, Permission.CHANGE_PROFILE_URLS):
|
||||||
user.website_url = form["website_url"].data
|
user.website_url = form["website_url"].data
|
||||||
user.donate_url = form["donate_url"].data
|
user.donate_url = form["donate_url"].data
|
||||||
|
|
||||||
|
|||||||
@@ -23,19 +23,20 @@ The process is as follows:
|
|||||||
|
|
||||||
## Setting up
|
## Setting up
|
||||||
|
|
||||||
### Github (automatic)
|
### GitHub (automatic)
|
||||||
|
|
||||||
1. Go to your package page.
|
1. Go to your package's page.
|
||||||
2. Make sure that the repository URL is set to a Github repository.
|
2. Make sure that the repository URL is set to a Github repository.
|
||||||
Only github.com is supported.
|
Only github.com is supported.
|
||||||
3. Go to "Create a release", and click "Setup webhook" at the top of the page.
|
3. Go to "Releases" > "+", and click "Setup webhook" at the top of the create release
|
||||||
|
page.
|
||||||
If you do not see this, either the repository isn't using Github or you do
|
If you do not see this, either the repository isn't using Github or you do
|
||||||
not have permission to use webhook releases (ie: you're not a Trusted Member).
|
not have permission to use webhook releases (ie: you're not a Trusted Member).
|
||||||
4. Grant ContentDB the ability to manage Webhooks.
|
4. Grant ContentDB the ability to manage Webhooks.
|
||||||
5. Set the event to either "New tag" or "Push". New tag is highlight recommended.
|
5. Set the event to either "New tag or Github Release" (highly recommended) or "Push".
|
||||||
|
|
||||||
N.B.: GitHub uses tags to power GitHub Releases, meaning that creating a webhook
|
N.B.: GitHub uses tags to power GitHub Releases, meaning that creating a webhook
|
||||||
on "new tag" will sync GitHub and ContentDB releases.
|
on "New tag" will sync GitHub and ContentDB releases.
|
||||||
|
|
||||||
### GitHub (manual)
|
### GitHub (manual)
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ The process is as follows:
|
|||||||
7. Set the events
|
7. Set the events
|
||||||
* If you want a rolling release, choose "just the push event".
|
* If you want a rolling release, choose "just the push event".
|
||||||
* Or if you want a stable release cycle based on tags,
|
* Or if you want a stable release cycle based on tags,
|
||||||
choose "Let me select" > Branch or tag creation.
|
choose "Let me select" > Branch or tag creation.
|
||||||
|
|
||||||
### GitLab (manual)
|
### GitLab (manual)
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class Permission(enum.Enum):
|
|||||||
UNAPPROVE_PACKAGE = "UNAPPROVE_PACKAGE"
|
UNAPPROVE_PACKAGE = "UNAPPROVE_PACKAGE"
|
||||||
TOPIC_DISCARD = "TOPIC_DISCARD"
|
TOPIC_DISCARD = "TOPIC_DISCARD"
|
||||||
CREATE_TOKEN = "CREATE_TOKEN"
|
CREATE_TOKEN = "CREATE_TOKEN"
|
||||||
|
CHANGE_PROFILE_URLS = "CHANGE_PROFILE_URLS"
|
||||||
|
|
||||||
# Only return true if the permission is valid for *all* contexts
|
# Only return true if the permission is valid for *all* contexts
|
||||||
# See Package.checkPerm for package-specific contexts
|
# See Package.checkPerm for package-specific contexts
|
||||||
@@ -192,7 +193,7 @@ class User(db.Model, UserMixin):
|
|||||||
return user.rank.atLeast(UserRank.EDITOR)
|
return user.rank.atLeast(UserRank.EDITOR)
|
||||||
elif perm == Permission.CHANGE_RANK or perm == Permission.CHANGE_DNAME:
|
elif perm == Permission.CHANGE_RANK or perm == Permission.CHANGE_DNAME:
|
||||||
return user.rank.atLeast(UserRank.MODERATOR)
|
return user.rank.atLeast(UserRank.MODERATOR)
|
||||||
elif perm == Permission.CHANGE_EMAIL:
|
elif perm == Permission.CHANGE_EMAIL or perm == Permission.CHANGE_PROFILE_URLS:
|
||||||
return user == self or (user.rank.atLeast(UserRank.MODERATOR) and user.rank.atLeast(self.rank))
|
return user == self or (user.rank.atLeast(UserRank.MODERATOR) and user.rank.atLeast(self.rank))
|
||||||
elif perm == Permission.CREATE_TOKEN:
|
elif perm == Permission.CREATE_TOKEN:
|
||||||
if user == self:
|
if user == self:
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
<h1 class="mt-0">{{ self.title() }}</h1>
|
<h1 class="mt-0">{{ self.title() }}</h1>
|
||||||
|
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
{{ _("Use carefully, as you may be held responsible for any damage caused by rogue scripts") }}
|
{{ _("API Tokens allow scripts to act on your behalf.") }}
|
||||||
|
{{ _("Be careful with what/whom you share tokens with, as you are responsible for your account's actions.") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if token %}
|
{% if token %}
|
||||||
|
|||||||
@@ -20,4 +20,10 @@
|
|||||||
|
|
||||||
{{ render_submit_field(form.submit) }}
|
{{ render_submit_field(form.submit) }}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<p class="mt-4">
|
||||||
|
You will need admin access to the repository.
|
||||||
|
When setting up hooks on an organisation,
|
||||||
|
<a href="{{ url_for('github.view_permissions') }}">make sure that you have granted access</a>.
|
||||||
|
</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
| <a href="{{ user.website_url }}" rel="nofollow">Website</a>
|
| <a href="{{ user.website_url }}" rel="nofollow">Website</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% if user == current_user %}
|
{% if user == current_user %}
|
||||||
<br>
|
<br>
|
||||||
<small class="text-muted">
|
<small class="text-muted">
|
||||||
@@ -73,6 +74,16 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
{% if user == current_user and user.github_username %}
|
||||||
|
<tr>
|
||||||
|
<td>Privacy:</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ url_for('github.view_permissions') }}">View ContentDB's GitHub Permissions</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if current_user.is_authenticated and current_user.rank.atLeast(current_user.rank.MODERATOR) %}
|
{% if current_user.is_authenticated and current_user.rank.atLeast(current_user.rank.MODERATOR) %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>Admin</td>
|
<td>Admin</td>
|
||||||
@@ -115,7 +126,7 @@
|
|||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Password:</td>
|
<td>Password:</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -153,6 +164,9 @@
|
|||||||
|
|
||||||
{% if user.checkPerm(current_user, "CHANGE_DNAME") %}
|
{% if user.checkPerm(current_user, "CHANGE_DNAME") %}
|
||||||
{{ render_field(form.display_name, tabindex=230) }}
|
{{ render_field(form.display_name, tabindex=230) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if user.checkPerm(current_user, "CHANGE_PROFILE_URLS") %}
|
||||||
{{ render_field(form.website_url, tabindex=232) }}
|
{{ render_field(form.website_url, tabindex=232) }}
|
||||||
{{ render_field(form.donate_url, tabindex=233) }}
|
{{ render_field(form.donate_url, tabindex=233) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -166,7 +180,9 @@
|
|||||||
{{ render_field(form.rank, tabindex=250) }}
|
{{ render_field(form.rank, tabindex=250) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ render_submit_field(form.submit, tabindex=280) }}
|
<p>
|
||||||
|
{{ render_submit_field(form.submit, tabindex=280) }}
|
||||||
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ beautifulsoup4~=4.6
|
|||||||
celery~=4.4
|
celery~=4.4
|
||||||
kombu~=4.6
|
kombu~=4.6
|
||||||
GitPython~=3.0
|
GitPython~=3.0
|
||||||
git-archive-all~=1.20
|
git-archive-all~=1.21
|
||||||
lxml~=4.2
|
lxml~=4.2
|
||||||
pillow~=7.0
|
pillow~=7.0
|
||||||
pyScss~=1.3
|
pyScss~=1.3
|
||||||
|
|||||||
Reference in New Issue
Block a user