diff --git a/mitama/app/templates/lists.macro.html b/mitama/app/templates/lists.macro.html index 3e360ac..b9e819d 100644 --- a/mitama/app/templates/lists.macro.html +++ b/mitama/app/templates/lists.macro.html @@ -15,24 +15,6 @@ {% endif %} {%- endmacro %} -{% macro userItemEx(user, id=None, link=None, small=False) -%} -{% if link != None %} - -{% else %} -
-{% endif %} - -
-
{{ user.name }}
-
{{ user.screen_name }}
- {{ caller() }} -
-{% if link != None %} -
-{% else %} -
-{% endif %} -{%- endmacro %} {% macro groupItem(group, id=None, link=None, tree=False, small=False) -%}
@@ -50,24 +32,6 @@ {% endif %}
{%- endmacro %} -{% macro groupItemEx(group, id=None, link=None, tree=False, small=False) -%} -
-
- - -
-
{{ group.name }}
-
{{ group.screen_name }}
- {{ caller() }} -
-
- {% if tree and group.groups.length != 0 %} -
- {{ tree(group.groups) }} -
- {% endif %} -
-{%- endmacro %} {% macro appItem(app, id=None, link=None, small=False) -%} {% if link != None %} @@ -86,22 +50,3 @@ {% endif %} {%- endmacro %} -{% macro appItemEx(app, id=None, link=None, small=False) -%} -{% if link != None %} - -{% else %} -
-{% endif %} - -
-
{{ app.name }}
-
{{ app.screen_name }}
-

{{ app.description }}

- {{ caller() }} -
-{% if link != None %} -
-{% else %} -
-{% endif %} -{%- endmacro %} diff --git a/mitama/models/nodes.py b/mitama/models/nodes.py index 48d0592..077433a 100644 --- a/mitama/models/nodes.py +++ b/mitama/models/nodes.py @@ -374,7 +374,8 @@ def is_ancestor(self, node): return True layer_ = list() for node_ in layer: - layer_.extend([node_.parent]) + if node_.parent is not None: + layer_.extend([node_.parent]) layer = layer_ return False diff --git a/mitama/portal/controller.py b/mitama/portal/controller.py index b648209..8d053be 100644 --- a/mitama/portal/controller.py +++ b/mitama/portal/controller.py @@ -441,6 +441,7 @@ class GroupsController(Controller): def create(self, req): template = self.view.get_template("group/create.html") groups = Group.list() + error = "" if req.method == "POST": form = GroupCreateForm(req.post()) try: @@ -454,12 +455,13 @@ def create(self, req): group.append(req.user) return Response.redirect(self.app.convert_url("/groups")) except ValidationError as err: - return Response.render( - template, - {"groups": groups, "icon": load_noimage_group(), "error": str(err)}, - ) + error = str(err) return Response.render( - template, {"groups": groups, "icon": load_noimage_group()} + template, { + "groups": groups, + "icon": load_noimage_group(), + "error": error + } ) def retrieve(self, req): @@ -474,14 +476,15 @@ def retrieve(self, req): def update(self, req): template = self.view.get_template("group/update.html") - roles = Role.list() - inner_roles = InnerRole.list() group = Group.retrieve(screen_name=req.params["id"]) + groups = list() for g in Group.list(): if not (group.is_ancestor(g) or group.is_descendant(g) or g == group): groups.append(g) users = list() + error = "" + message = "" for u in User.list(): if not group.is_in(u): users.append(u) @@ -491,6 +494,7 @@ def update(self, req): icon = resize_icon(form["icon"]) if form["icon"] is not None else group.icon group.screen_name = form["screen_name"] group.name = form["name"] + group.parent = Group.retrieve(form["parent"]) if form["parent"] is not None else None for role in form["roles"]: group.roles.append(Role.retrieve(screen_name=role)) group.icon = icon @@ -501,39 +505,16 @@ def update(self, req): rel = UserGroup.retrieve(group = group, user = User.retrieve(user)) rel.roles = [InnerRole.retrieve(screen_name = role) for role in roles] group.update() - return Response.render( - template, - { - "message": "変更を保存しました", - "group": group, - "screen_name": group.screen_name, - "name": group.name, - "all_groups": groups, - "all_users": users, - "icon": group.icon, - "roles": Role.list(), - "inner_roles": inner_roles - }, - ) + message = "変更を保存しました" except ValidationError as err: error = str(err) - return Response.render( - template, - { - "error": error, - "all_groups": groups, - "all_users": users, - "group": group, - "screen_name": form["screen_name"], - "name": form["name"], - "icon": group.icon, - "roles": Role.list(), - "inner_roles": inner_roles - }, - ) + roles = Role.list() + inner_roles = InnerRole.list() return Response.render( template, { + "message": message, + "error": error, "group": group, "all_groups": groups, "all_users": users, diff --git a/mitama/portal/static/mitama-style.css b/mitama/portal/static/mitama-style.css index b14aabb..f03512b 100644 --- a/mitama/portal/static/mitama-style.css +++ b/mitama/portal/static/mitama-style.css @@ -12,6 +12,11 @@ object-fit: cover; } +:root { + --main-text-lighter: #777; + --main-color: #ccc; +} + .no-item { color: var(--main-text-lighter); font-size: 0.8rem; @@ -36,7 +41,6 @@ grid-column: 2/3; grid-template-columns: 56px 1fr; grid-gap: 16px; - padding: 8px; } .group-item .profile .icon { width: 56px; @@ -54,7 +58,7 @@ font-weight: bold; } .group-item .profile .detail .screen-name { - font-size: 0.85rem; + font-size: 0.75rem; color: var(--main-text-lighter); } .group-item.small .profile { @@ -65,20 +69,20 @@ height: 32px; border-radius: 16px; } +.group-item.small .profile .screen-name { + font-size: 0.9rem; + color: #000; + font-weight: 600; +} +.group-item.small .profile .name { + display: none; +} .children { grid-column: 2/3; + grid-gap: 8px; position: relative; } -.children::before { - content: ""; - display: block; - position: absolute; - width: 2px; - height: calc(100% - 45px); - left: 16px; - background: var(--main-color); -} .children .branch { width: 24px; display: block; @@ -111,7 +115,6 @@ grid-gap: 16px; text-decoration: none; color: var(--main-text); - padding: 8px; } .user-item .icon, .invite-item .icon { @@ -129,6 +132,7 @@ .invite-item .detail { display: flex; flex-direction: column; + justify-content: center; } .user-item .detail .name, .invite-item .detail .name { @@ -137,7 +141,7 @@ } .user-item .detail .screen-name, .invite-item .detail .screen-name { - font-size: 0.85rem; + font-size: 0.75rem; color: var(--main-text-lighter); } .user-item .detail .buttons, @@ -158,13 +162,24 @@ } .user-item.small, .invite-item.small { - grid-template-columns: 32px 1fr; + grid-template-columns: 40px 1fr; + grid-gap: 8px; } .user-item.small .icon, .invite-item.small .icon { - width: 32px; - height: 32px; - border-radius: 16px; + width: 40px; + height: 40px; + border-radius: 20px; +} +.user-item.small .screen-name, +.invite-item.small .screen-name { + font-size: 0.9rem; + color: #000; + font-weight: 600; +} +.user-item.small .name, +.invite-item.small .name { + display: none; } .member-control-list h4 { @@ -197,7 +212,7 @@ font-weight: bold; } .member-control-item .detail .screen-name { - font-size: 0.85rem; + font-size: 0.65rem; color: var(--main-text-lighter); } .member-control-item .actions { @@ -216,6 +231,14 @@ height: 32px; border-radius: 16px; } +.member-control-item.small .screen-name { + color: #000; + font-weight: 600; + font-size: 0.9rem; +} +.member-control-item.small .name { + display: none; +} .app-list { display: grid; diff --git a/mitama/portal/static/mitama-style.css.map b/mitama/portal/static/mitama-style.css.map index 198c208..cf5027f 100644 --- a/mitama/portal/static/mitama-style.css.map +++ b/mitama/portal/static/mitama-style.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["../../../scss/main.scss","../../../scss/list.scss"],"names":[],"mappings":"AAAA;EACI;EACA;;;AAEJ;EACI;EACA;;;AAEJ;EACI;;;ACRJ;EACI;EACA;EACA;EACA;EACA;EACA;;;AAGJ;EACI;EACA;;AACA;EACI;EACA;;AAEJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;;AACA;EACI;EACA;;AAEJ;EACI;EACA;;AAKR;EACI;;AACA;EACI;EACA;EACA;;;AAMhB;EACI;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAOR;AAAA;EACI;EACA;;;AAIR;AAAA;EAEI;EACA;EACA;EACA;EACA;EACA;;AACA;AAAA;EACI;EACA;EACA;EACA;EACA;;AAEJ;AAAA;EACI;;AAEJ;AAAA;EACI;EACA;;AACA;AAAA;EACI;EACA;;AAEJ;AAAA;EACI;EACA;;AAEJ;AAAA;EACI;EACA;;AACA;AAAA;EACI;;AAEJ;AAAA;EACI;EACA;EACA;EACA;;AAIZ;AAAA;EACI;;AACA;AAAA;EACI;EACA;EACA;;;AAMR;EACI;EACA;;;AAIR;EACI;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;;AACA;EACI;EACA;;AAEJ;EACI;EACA;;AAGR;EACI;EACA;EACA;;AACA;EACI;;AAGR;EACI;;AACA;EACI;EACA;EACA;;;AAKZ;EACI;EACA;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;;AACA;EACI;EACA;;AAEJ;EACI;;AAEJ;EACI;EACA","file":"mitama-style.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../../../scss/main.scss","../../../scss/list.scss"],"names":[],"mappings":"AAAA;EACI;EACA;;;AAEJ;EACI;EACA;;;AAEJ;EACI;;;ACTJ;EACI;EACA;;;AAEJ;EACI;EACA;EACA;EACA;EACA;EACA;;;AAGJ;EACI;EACA;;AACA;EACI;EACA;;AAEJ;EACI;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;;AACA;EACI;EACA;;AAEJ;EACI;EACA;;AAKR;EACI;;AACA;EACI;EACA;EACA;;AAEJ;EACI;EACA;EACA;;AAEJ;EACI;;;AAMhB;EACI;EACA;EACA;;AACA;EACI;EACA;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAOR;AAAA;EACI;EACA;;;AAIR;AAAA;EAEI;EACA;EACA;EACA;EACA;;AACA;AAAA;EACI;EACA;EACA;EACA;EACA;;AAEJ;AAAA;EACI;;AAEJ;AAAA;EACI;EACA;EACA;;AACA;AAAA;EACI;EACA;;AAEJ;AAAA;EACI;EACA;;AAEJ;AAAA;EACI;EACA;;AACA;AAAA;EACI;;AAEJ;AAAA;EACI;EACA;EACA;EACA;;AAIZ;AAAA;EACI;EACA;;AACA;AAAA;EACI;EACA;EACA;;AAEJ;AAAA;EACI;EACA;EACA;;AAEJ;AAAA;EACI;;;AAMR;EACI;EACA;;;AAIR;EACI;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;;AACA;EACI;EACA;;AAEJ;EACI;EACA;;AAGR;EACI;EACA;EACA;;AACA;EACI;;AAGR;EACI;;AACA;EACI;EACA;EACA;;AAEJ;EACI;EACA;EACA;;AAEJ;EACI;;;AAKZ;EACI;EACA;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;;AACA;EACI;EACA;;AAEJ;EACI;;AAEJ;EACI;EACA","file":"mitama-style.css"} \ No newline at end of file diff --git a/mitama/portal/templates/group/list.html b/mitama/portal/templates/group/list.html index d3874ca..696082a 100644 --- a/mitama/portal/templates/group/list.html +++ b/mitama/portal/templates/group/list.html @@ -28,7 +28,9 @@
{% if groups|length %} {% for group in groups recursive %} +
{{ lists.groupItem(group, link=url("/groups/" + group.screen_name), tree=loop) }} +
{% endfor %} {% else%}
グループは存在しません
diff --git a/mitama/portal/templates/group/retrieve.html b/mitama/portal/templates/group/retrieve.html index 760769f..b84434b 100644 --- a/mitama/portal/templates/group/retrieve.html +++ b/mitama/portal/templates/group/retrieve.html @@ -29,7 +29,9 @@

{{group.name}}

メンバー

{% for user in group.users %} +
{{ lists.userItem(user, link=url('/users/'+user.screen_name)) }} +
{% endfor %}
diff --git a/mitama/portal/templates/group/update.html b/mitama/portal/templates/group/update.html index d8573be..a85544e 100644 --- a/mitama/portal/templates/group/update.html +++ b/mitama/portal/templates/group/update.html @@ -35,9 +35,10 @@

{{ group.name }}の設定

- + + {% for group_ in all_groups %} + {% endfor %}
@@ -68,32 +69,37 @@

{% for user in group.users %} - {% call lists.userItemEx(user, id='user_'+user._id) %} -
設定
-
- - {% for inner_role in inner_roles %} -
- - +
+
+ {{ lists.userItem(user, id='user_'+user._id) }} +
+ +
- {% endfor %} - {% if permission('update_group', request.user) or inner_permission('remove_user', group, request.user) %} -
- +
+ + {% for inner_role in inner_roles %} +
+ + +
+ {% endfor %} + {% if permission('update_group', request.user) or inner_permission('remove_user', group, request.user) %} +
+ +
+ {% endif %}
- {% endif %}
- {% endcall %} {% endfor %}
- - +{% extends "base/plain" %} +{% block body %} +{% for user in users %} +{{ lists.userItem(user) }} +{% endfor %} +{% for user in users %} +{{ lists.userItem(user, small=True) }} +{% endfor %} +{% endblock %}