By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Full label editing

roundabout,
created on Monday, 22 July 2024, 12:31:31 (1721651491), received on Wednesday, 31 July 2024, 06:54:51 (1722408891)
Author identity: vlad <vlad.muntoiu@gmail.com>

74604d9b4671a057b6600e77b5a6dec62c98f5c7

app.py

@@ -1755,6 +1755,38 @@ def repository_settings_add_label(username, repository):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                return flask.redirect(f"/{username}/{repository}/settings", 303)
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        @repositories.route("/<username>/<repository>/settings/delete-label", methods=["POST"])
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        def repository_settings_delete_label(username, repository):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            if get_permission_level(flask.session.get("username"), username, repository) != 2:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                flask.abort(401)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            repo_data = db.session.get(Repo, f"/{username}/{repository}")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            label = db.session.get(Label, flask.request.form.get("id"))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            db.session.delete(label)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            db.session.commit()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            return flask.redirect(f"/{username}/{repository}/settings", 303)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        @repositories.route("/<username>/<repository>/settings/edit-label", methods=["POST"])
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        def repository_settings_edit_label(username, repository):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            if get_permission_level(flask.session.get("username"), username, repository) != 2:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                flask.abort(401)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            repo_data = db.session.get(Repo, f"/{username}/{repository}")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            label = db.session.get(Label, flask.request.form.get("id"))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            label.name = flask.request.form.get("label")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            label.colour_hex = flask.request.form.get("colour")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            db.session.commit()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            return flask.redirect(f"/{username}/{repository}/settings", 303)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            @repositories.route("/<username>/<repository>/settings/delete", methods=["POST"])
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            def repository_settings_delete(username, repository):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                if username != flask.session.get("username"):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

misc_utils.py

@@ -37,7 +37,6 @@ def get_visibility(username, repository):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            def get_favourite(logged_in, username, repository):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            print(logged_in, username, repository)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                relationship = RepoFavourite.query.filter_by(user_username=logged_in,
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                                             repo_route=f"/{username}/{repository}").first()
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                return relationship
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

static/style.css

@@ -680,3 +680,32 @@ small {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                font-size: inherit;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                font-weight: 150;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        .post-label {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            color: var(--color-primary-text);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            text-shadow: 0.0625em 0.0625em #000000ff;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            padding-inline: 0.375rem;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            border-radius: 100vmax;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        .post-label.removable {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            cursor: pointer;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            color: var(--color-primary-text);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            text-decoration: none;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        .post-label.removable:hover {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            color: var(--color-primary-text);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            text-decoration: line-through;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        .post-label.editable {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            cursor: pointer;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            color: var(--color-primary-text);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            text-decoration: none;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        .post-label.editable:hover {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            color: var(--color-primary-text);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            text-decoration: underline;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

templates/repository/repo-settings.html

@@ -67,10 +67,35 @@ Note that only branch names are supported, not other references like tags or com

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                        {% trans %}Even if this repository is private, the site will not have access control.{% endtrans %}
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                    </p>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                    <h3>{% trans %}Forum labels{% endtrans %}</h3>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                <dialog id="edit-label">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    <article class="card">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                        <section class="card-main">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                            <form method="dialog" id="close-edit-label"></form>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                            <form method="POST" action="/{{ username }}/{{ repository }}/settings/edit-label">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                <input type="hidden" name="id" id="edit-label-id">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                <x-vbox>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                    <label>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                        {% trans %}Label name{% endtrans %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                        <input type="text" id="edit-label-name" name="label" required>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                    </label>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                    <label>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                        {% trans %}Label colour{% endtrans %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                        <input type="color" id="edit-label-colour" name="colour" value="#009688" required>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                    </label>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                    <x-buttonbox>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                        <button type="submit">{% trans %}Save{% endtrans %}</button>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                        <button type="submit" formaction="/{{ username }}/{{ repository }}/settings/delete-label">{% trans %}Delete{% endtrans %}</button>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                        <button type="submit" form="close-edit-label">{% trans %}Cancel{% endtrans %}</button>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                    </x-buttonbox>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                </x-vbox>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                            </form>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                        </section>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    </article>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                </dialog>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                    <ul>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                        {% for label in repo_data.labels %}
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                            <li>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                            {{ label }}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                            <span class="post-label editable" onclick="document.getElementById('edit-label').showModal(); document.getElementById('edit-label-id').value = '{{ label.identifier }}'; document.getElementById('edit-label-name').value = '{{ label.name }}'; document.getElementById('edit-label-colour').value = '{{ label.colour_hex }}';" style="background-color: {{ label.colour_hex }}">{{ label.name }}</span>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                            </li>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                        {% endfor %}
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                    </ul>