Skip to content

Commit

Permalink
Merge pull request #84 from mitama-org/hotfix/portal-group
Browse files Browse the repository at this point in the history
[fix] メンバー追加時の不具合を修正
  • Loading branch information
takuan517 authored Oct 5, 2020
2 parents 727fb2f + 0d1df00 commit feb2595
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions mitama/http/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def get(self, key, default = None):
return self[key]
else:
return default
def getlist(self, key, default = list()):
if key in self:
return self._field_storage.getlist(key)
else:
return default
@classmethod
def parse_body(cls, rfile, content_type, length):
environ = {
Expand Down
9 changes: 4 additions & 5 deletions mitama/portal/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,10 @@ def create(self, req):
group.screen_name = post['screen_name']
group.icon = post['icon'].file.read() if "icon" in post else None
group.create()
print('created')
if "parent" in post and post['parent'] != '':
Group.retrieve(int(post['parent'])).append(group)
group.append(req.user)
print('append')
UpdateGroupPermission.accept(req.user, group)
print('accept')
return Response.redirect(self.app.convert_url("/groups"))
except Exception as err:
error = str(err)
Expand Down Expand Up @@ -369,16 +366,18 @@ def append(self, req):
group = Group.retrieve(screen_name = req.params['id'])
nodes = list()
if 'user' in post:
for uid in post['user']:
for uid in post.getlist('user'):
try:
nodes.append(User.retrieve(int(uid)))
except Exception as err:
print(err)
pass
if 'group' in post:
for gid in post['group']:
for gid in post.getlist('group'):
try:
nodes.append(Group.retrieve(int(gid)))
except Exception as err:
print(err)
pass
group.append_all(nodes)
except Exception as err:
Expand Down
2 changes: 1 addition & 1 deletion mitama/portal/templates/group/retrieve.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h2 class="mini-title">メンバー</h2>
<div class='name'>{{ user.name }}</div>
<div class='screen-name'>{{ user.screen_name }}</div>
</div>
</div>
</a>
{% endfor %}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions mitama/portal/templates/group/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ <h4>ユーザー</h4>
<input type='search' oninput='reload_list("#user")' placeholder='検索'>
{% for user in all_users %}
<label class='item-container'>
<input type='checkbox' name='user[]' value='{{user.id}}'>
<input type='checkbox' name='user' value='{{user.id}}'>
<div class='item'>
<img src='{{dataurl(user.icon)}}' class='user-icon'>
<div class='detail'>
Expand All @@ -190,7 +190,7 @@ <h4>グループ</h4>
<input type='search' oninput='reload_list("#group")' placeholder='検索'>
{% for group in all_groups %}
<label class='item-container'>
<input type='checkbox' name='group[]' value='{{group.id}}'>
<input type='checkbox' name='group' value='{{group.id}}'>
<div class='item'>
<img src='{{dataurl(group.icon)}}' class='icon'>
<div class='detail'>
Expand Down

0 comments on commit feb2595

Please sign in to comment.