【发布时间】:2018-11-05 19:33:12
【问题描述】:
我有一个包含不同客户(房东、租户)的门户
他们有一个注册页面。当他们注册时,我会使用角色适当地标记他们。
当他们登录时,他们要做的第一件事就是填写他们的个人资料。为此,我创建了一个页面 profile.html...
除了少数之外,这两个用户的字段几乎相似。我对房东有一些属性,对租户有一些属性。但是它们都有一些相似的字段,例如 first_name、last_name、phone、age、sex 等......
目前,我维护着两个不同的配置文件表和一个 profile.html 页面。
我将它们发送到 profile.html 并且我正在使用
{% if user == 'landlord' %}
<html
<body>
profile pagefor landlord
</body>
</html>
{% endif %}
{% if user == 'tenant' %}
<html
<body>
profile pagefor tenant
</body>
</html>
{% endif %}
如果我为每个用户重复整个 HTML 块,上述结构的问题。
一旦用户填写了他们的个人资料,我会向他们展示只读的 profile.html 页面,例如
{% if user == 'landlord' and profile_filled %}
<html
<body>
read only profile page for landlord
</body>
</html>
{% endif %}
{% if user == 'tenant' and profile_filled %}
<html
<body>
read only profile page for tenant
</body>
</html>
{% endif %}
页面 profile.html 使用这些 IF 变得太长......
有办法简化吗?
【问题讨论】:
标签: flask flask-sqlalchemy flask-security