Add unlisted visibility level
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -7,5 +7,5 @@
|
|||||||
|Group|Description|
|
|Group|Description|
|
||||||
|-----|-----------|
|
|-----|-----------|
|
||||||
|k-space:inventory:audit|Update last time item information confirmed to be accurate|
|
|k-space:inventory:audit|Update last time item information confirmed to be accurate|
|
||||||
|k-space:inventory:edit|Edit all items that are not keys|
|
|k-space:inventory:edit|Edit all items that are not keys. Browse items with private visibility.|
|
||||||
|k-space:inventory:keys|Edit keys|
|
|k-space:inventory:keys|Edit keys|
|
||||||
|
@@ -42,7 +42,7 @@ def view_inventory_view(item_id):
|
|||||||
return abort(404)
|
return abort(404)
|
||||||
item_user = item.get("inventory", {}).get("user", {}).get("username", None)
|
item_user = item.get("inventory", {}).get("user", {}).get("username", None)
|
||||||
if not user:
|
if not user:
|
||||||
if not item["inventory"].get("public"):
|
if item["inventory"].get("visibility") not in ["public"]:
|
||||||
return do_login()
|
return do_login()
|
||||||
template = "inventory_view_public.html"
|
template = "inventory_view_public.html"
|
||||||
redirect_url = urllib.parse.quote_plus(request.full_path)
|
redirect_url = urllib.parse.quote_plus(request.full_path)
|
||||||
@@ -127,7 +127,7 @@ class InventoryForm(Form):
|
|||||||
owner = FormField(MemberForm, label="Owner")
|
owner = FormField(MemberForm, label="Owner")
|
||||||
user = FormField(MemberForm, label="Current User")
|
user = FormField(MemberForm, label="Current User")
|
||||||
usable = BooleanField("Usable")
|
usable = BooleanField("Usable")
|
||||||
public = BooleanField("Public")
|
visibility = SelectField("Visibility", choices=['public', 'private', 'unlisted'])
|
||||||
|
|
||||||
class HardwareForm(Form):
|
class HardwareForm(Form):
|
||||||
serial = StringField("Serial Number")
|
serial = StringField("Serial Number")
|
||||||
@@ -151,8 +151,6 @@ class InventoryItemForm(CustomForm):
|
|||||||
location = StringField('Location')
|
location = StringField('Location')
|
||||||
def setup_defaults_add(self):
|
def setup_defaults_add(self):
|
||||||
setup_default_owner(self.inventory.form.owner.form.username)
|
setup_default_owner(self.inventory.form.owner.form.username)
|
||||||
self.inventory.form.public.render_kw = {"checked": "checked"}
|
|
||||||
self.inventory.form.public.data = "y"
|
|
||||||
|
|
||||||
|
|
||||||
def check_edit_permission(item_id):
|
def check_edit_permission(item_id):
|
||||||
@@ -436,14 +434,26 @@ def view_inventory(slug=None):
|
|||||||
template = "inventory.html"
|
template = "inventory.html"
|
||||||
public_view = False
|
public_view = False
|
||||||
login_user = read_user()
|
login_user = read_user()
|
||||||
|
|
||||||
if not login_user:
|
if not login_user:
|
||||||
q.update({"inventory.public": True})
|
q.update({"inventory.visibility": {"$eq": "public"}})
|
||||||
template = "inventory_public.html"
|
template = "inventory_public.html"
|
||||||
public_view = True
|
public_view = True
|
||||||
else:
|
else:
|
||||||
fields.append(("inventory.owner.username", "Owner", str))
|
fields.append(("inventory.owner.username", "Owner", str))
|
||||||
fields.append(("inventory.user.username", "User", str))
|
fields.append(("inventory.user.username", "User", str))
|
||||||
can_audit = "k-space:inventory:audit" in login_user.get("groups", [])
|
can_audit = "k-space:inventory:audit" in login_user.get("groups", [])
|
||||||
|
can_edit_all = "k-space:inventory:edit" in login_user.get("groups", [])
|
||||||
|
v = ["public", "unlisted"]
|
||||||
|
if can_edit_all:
|
||||||
|
v.append("private")
|
||||||
|
q.update({
|
||||||
|
"$or": [
|
||||||
|
{"inventory.visibility": {"$in": v}},
|
||||||
|
{"inventory.owner.username": login_user.get('username', False)}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
if slug and not public_view:
|
if slug and not public_view:
|
||||||
template = "inventory_pick.html"
|
template = "inventory_pick.html"
|
||||||
if request.path.startswith("/m/inventory/clone-with-slug"):
|
if request.path.startswith("/m/inventory/clone-with-slug"):
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Slug</th>
|
<th>Slug</th>
|
||||||
<th>Public</th>
|
<th>Visibility</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
<th>Location</th>
|
<th>Location</th>
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
<a href="http://k6.ee/{{ item.shortener.slug }}">{{ item.shortener.slug }}</a>
|
<a href="http://k6.ee/{{ item.shortener.slug }}">{{ item.shortener.slug }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{% if item.inventory.public %}<i class="material-icons">check_circle</i>{% else %} {% endif %}</td>
|
<td>{{ item.inventory.visibility }}</td>
|
||||||
<td><a href="/m/inventory/{{ item._id }}/view">{{ item | format_name }} {{ item.comment }}</a></td>
|
<td><a href="/m/inventory/{{ item._id }}/view">{{ item | format_name }} {{ item.comment }}</a></td>
|
||||||
<td>{{ item.type }}</td>
|
<td>{{ item.type }}</td>
|
||||||
<td>{{ item.location }}</td>
|
<td>{{ item.location }}</td>
|
||||||
|
@@ -97,6 +97,11 @@
|
|||||||
<td>{{ form.location }}</td>
|
<td>{{ form.location }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Visibility</td>
|
||||||
|
<td>{{ form.inventory.visibility }}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -107,13 +112,6 @@
|
|||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
|
||||||
<label>
|
|
||||||
{{ form.inventory.public }}
|
|
||||||
<span>Public, show this inventory item for unauthenticated users</span>
|
|
||||||
</label>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h5>Tags</h5>
|
<h5>Tags</h5>
|
||||||
<div class="placeholder-dark chips">
|
<div class="placeholder-dark chips">
|
||||||
<input style="width: auto !important;">
|
<input style="width: auto !important;">
|
||||||
|
@@ -125,8 +125,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tooltip" data-tooltip="Unauthenticated user can see this in public list">Public</td>
|
<td class="tooltip" data-tooltip="Who can see the item">Visibility</td>
|
||||||
<td>{% if item.inventory.public %}<i class="material-icons">check_circle</i>{% endif %}</td>
|
<td>{{ item.inventory.visibility }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
Reference in New Issue
Block a user