forked from MarseyWorld/MarseyWorld
remove relinking
parent
a5b006e9ad
commit
ef2bda6920
|
@ -1,13 +1,7 @@
|
|||
function submitAddAlt(element, username) {
|
||||
const isLinking = element.id == 'add-alt-form-link';
|
||||
const otherElement = isLinking ? document.getElementById('add-alt-form-delink') : document.getElementById('add-alt-form-link');
|
||||
if (!otherElement) return;
|
||||
element.disabled = true;
|
||||
otherElement.disabled = true;
|
||||
element.classList.add('disabled');
|
||||
otherElement.classList.add('disabled');
|
||||
const form = new FormData();
|
||||
if (!isLinking) form.append('deleted', 'true');
|
||||
form.append('other_username', document.getElementById('link-input-other').value);
|
||||
const xhr = createXhrWithFormKey(`/@${username}/alts/`, 'POST', form);
|
||||
xhr[0].onload = function() {
|
||||
|
@ -24,10 +18,17 @@ function submitAddAlt(element, username) {
|
|||
} else {
|
||||
showToast(false, getMessageFromJsonData(false, data));
|
||||
element.disabled = false;
|
||||
otherElement.disabled = false;
|
||||
element.classList.remove('disabled');
|
||||
otherElement.classList.remove('disabled');
|
||||
}
|
||||
}
|
||||
xhr[0].send(xhr[1]);
|
||||
}
|
||||
|
||||
function delink(t, url) {
|
||||
postToast(t, url,
|
||||
{},
|
||||
() => {
|
||||
t.parentElement.parentElement.remove()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -641,35 +641,27 @@ def admin_add_alt(v:User, username):
|
|||
g.db.add(ma)
|
||||
return {"message": f"{word} @{user1.username} and @{user2.username} successfully!"}
|
||||
|
||||
@app.route('/@<username>/alts/<int:other>/deleted', methods=["PUT", "DELETE"])
|
||||
@app.post('/@<username>/alts/<int:other>/deleted')
|
||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
|
||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID)
|
||||
@admin_level_required(PERMS['USER_LINK'])
|
||||
def admin_delink_relink_alt(v:User, username, other):
|
||||
is_delinking = request.method == 'PUT' # we're adding the 'deleted' state if a PUT request
|
||||
user1 = get_user(username)
|
||||
user2 = get_account(other)
|
||||
ids = [user1.id, user2.id]
|
||||
a = g.db.query(Alt).filter(Alt.user1.in_(ids), Alt.user2.in_(ids)).one_or_none()
|
||||
if not a: abort(404)
|
||||
a.deleted = is_delinking
|
||||
g.db.add(a)
|
||||
g.db.flush()
|
||||
check_for_alts(user1)
|
||||
check_for_alts(user2)
|
||||
word = 'Delinked' if is_delinking else 'Relinked'
|
||||
ma_word = 'delink' if is_delinking else 'link'
|
||||
note = f'from @{user2.username}' if is_delinking else f'with @{user2.username} (relinked)'
|
||||
g.db.delete(a)
|
||||
|
||||
ma = ModAction(
|
||||
kind=f"{ma_word}_accounts",
|
||||
kind=f"delink_accounts",
|
||||
user_id=v.id,
|
||||
target_user_id=user1.id,
|
||||
_note=note
|
||||
_note=f'from @{user2.username}'
|
||||
)
|
||||
g.db.add(ma)
|
||||
|
||||
return {"message": f"{word} @{user1.username} and @{user2.username} successfully!"}
|
||||
return {"message": f"Delinked @{user1.username} and @{user2.username} successfully!"}
|
||||
|
||||
|
||||
@app.get("/admin/removed/posts")
|
||||
|
|
|
@ -26,9 +26,7 @@
|
|||
<th>#</th>
|
||||
<th>Name</th>
|
||||
<th class="disable-sort-click">Account Created</th>
|
||||
<th>Alt Link Created</th>
|
||||
<th>Manual</th>
|
||||
<th class="disable-sort-click">Delinked</th>
|
||||
<th class="disable-sort-click">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -37,11 +35,9 @@
|
|||
<td>{{loop.index}}</td>
|
||||
<td>{% include "user_in_table.html" %}</td>
|
||||
<td>{{user.created_utc|timestamp}}</td>
|
||||
<td>{{user._alt_created_utc|timestamp}}</td>
|
||||
<td>{{user._is_manual}}</td>
|
||||
<td>
|
||||
<button type="button" id="delink-alt-{{u.id}}-{{user.id}}" class="btn btn-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/@{{u.username}}/alts/{{user.id}}/deleted', 'delink-alt-{{u.id}}-{{user.id}}', 'relink-alt-{{u.id}}-{{user.id}}', 'd-none', 'null', 'PUT')">Delink</button>
|
||||
<button type="button" id="relink-alt-{{u.id}}-{{user.id}}" class="btn btn-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/@{{u.username}}/alts/{{user.id}}/deleted', 'relink-alt-{{u.id}}-{{user.id}}', 'delink-alt-{{u.id}}-{{user.id}}', 'd-none', 'null', 'DELETE')">Relink</button>
|
||||
<button type="button" id="delink-alt-{{u.id}}-{{user.id}}" class="btn btn-danger" data-nonce="{{g.nonce}}" data-onclick="delink(this,'/@{{u.username}}/alts/{{user.id}}/deleted')">Delink</button>
|
||||
<a class="btn btn-secondary" href="/@{{user.username}}/alts">Alts</a>
|
||||
{% if v.admin_level >= PERMS['VIEW_ALT_VOTES'] %}
|
||||
<a class="btn btn-secondary" href="/admin/alt_votes/?u1={{u.username}}&u2={{user.username}}">Alt Votes</a>
|
||||
|
@ -53,14 +49,10 @@
|
|||
</div>
|
||||
<section id="add-alt" class="rounded rounded-section p-3">
|
||||
<h5>Add Alt</h5>
|
||||
<p>This tool allows you to add an alt either linked or delinked.<br>
|
||||
Adding linked will link the two alts together manually, while adding delinked will attempt to delink alts whereever possible.<br>
|
||||
You're on your own for reversing any propagation though.
|
||||
</p>
|
||||
<p>This tool allows you to link an alt.</p>
|
||||
<label for="link-input-other">Other Username</label>
|
||||
<input autocomplete="off" id="link-input-other" type="text" class="form-control mb-2" name="other_username" placeholder="Other Username">
|
||||
<button id="add-alt-form-link" class="btn btn-danger mr-3" data-areyousure="submitAddAlt(this, '{{u.username}}')" data-nonce="{{g.nonce}}" data-onclick="areyousure(this)">Add Alt Linked</button>
|
||||
<button id="add-alt-form-delink" class="btn btn-danger" data-areyousure="submitAddAlt(this, '{{u.username}}')" data-nonce="{{g.nonce}}" data-onclick="areyousure(this)">Add Alt Delinked</button>
|
||||
<button id="add-alt-form-link" class="btn btn-danger mr-3" data-areyousure="submitAddAlt(this, '{{u.username}}')" data-nonce="{{g.nonce}}" data-onclick="areyousure(this)">Add Alt</button>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
|
|
Loading…
Reference in New Issue