Skip to content

Commit

Permalink
[update]
Browse files Browse the repository at this point in the history
  • Loading branch information
boke0 committed Mar 4, 2021
1 parent 688b9fb commit 21dcc22
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
9 changes: 5 additions & 4 deletions mitama/app/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ def __init__(self, data=None):
k_ = k.split('.')
name = k_[0]
key = '.'.join(k_[1:])
if field.listed:
field.data[key] = data.getlist(k)
else:
field.data[key] = data.get(k)
if name == field.name:
if field.listed:
field.data[key] = data.getlist(k)
else:
field.data[key] = data.get(k)
elif field.listed:
field.data = data.getlist(field.name)
elif field.name in data:
Expand Down
16 changes: 8 additions & 8 deletions mitama/portal/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,19 @@ def settings(self, request):
role.screen_name = form['role_screen_name']
role.name = form['role_name'] if form['role_name'] is not None else form['role_screen_name']
role.create()
for role_screen_name, role_permissions in form['role'].items():
role = Role.retrieve(screen_name = role_screen_name)
role.permissions = [Permission.retrieve(screen_name=permission) for permission in role_permissions]
role.update()
for permission_screen_name, permission_roles in form['permission'].items():
permission = Permission.retrieve(screen_name = permission_screen_name)
permission.roles = [Role.retrieve(screen_name=role) for role in permission_roles]
permission.update()
if form["inner_role_screen_name"] is not None:
inner_role = InnerRole()
inner_role.screen_name = form['inner_role_screen_name']
inner_role.name = form['inner_role_name'] if form['inner_role_name'] is not None else form['inner_role_screen_name']
inner_role.create()
for inner_role_screen_name, inner_role_permissions in form['inner_role'].items():
inner_role = InnerRole.retrieve(screen_name = inner_role_screen_name)
inner_role.permissions = [InnerPermission.retrieve(screen_name=permission) for permission in inner_role_permissions]
inner_role.update()
for inner_permission_screen_name, inner_permission_roles in form['inner_permission'].items():
inner_permission = InnerPermission.retrieve(screen_name=inner_permission_screen_name)
inner_permission.roles = [InnerRole.retrieve(screen_name=role) for role in inner_permission_roles]
inner_permission.update()
with open(self.app.project_dir / "welcome_message.md", "w") as f:
f.write(welcome_message_)
error = "変更を保存しました"
Expand Down
4 changes: 2 additions & 2 deletions mitama/portal/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class SettingsForm(Form):
welcome_message = Field(label="ウェルカムボード", required=True)
role_name = Field(label='役割名')
role_screen_name = Field(label='役割ID', regex=r'^([0-9a-zA-Z_-]+)$')
role = DictField(listed=True)
permission = DictField(listed=True)
inner_role_name = Field(label='グループ役割名')
inner_role_screen_name = Field(label='グループ役割ID', regex=r'^([0-9a-zA-Z_-]+)$')
inner_role = DictField(listed=True)
inner_permission = DictField(listed=True)

class LoginForm(Form):
screen_name = Field(label="ログイン名", required=True)
Expand Down
8 changes: 4 additions & 4 deletions mitama/portal/templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ <h4 class='mt-3 mb-3'>権限割り当て</h4>
<td>
<input
type='checkbox'
name='role.{{role.screen_name}}'
value='{{permission.screen_name}}'
name='permission.{{permission.screen_name}}'
value='{{role.screen_name}}'
{% if role in permission.roles %}
checked
{% endif %}
Expand Down Expand Up @@ -71,8 +71,8 @@ <h4 class='mt-3 mb-3'>グループ内権限割り当て</h4>
<td>
<input
type='checkbox'
name='inner_role.{{role.screen_name}}'
value='{{permission.screen_name}}'
name='inner_permission.{{permission.screen_name}}'
value='{{role.screen_name}}'
{% if role in permission.roles %}
checked
{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion mitama/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import inspect
import smtplib
import argparse
from traceback import print_exc
from pathlib import Path, PosixPath
from email.mime.text import MIMEText
import json
Expand Down Expand Up @@ -112,7 +113,7 @@ def wsgi(self, env, start_response):
DatabaseManager.start_session()
body = super().wsgi(env, start_response)
except Exception as err:
print(err)
print_exc(err)
DatabaseManager.rollback_session()
request = Request(env)
body = self.error(request, 500).start(request, start_response)
Expand Down

0 comments on commit 21dcc22

Please sign in to comment.