diff --git a/src/handlers/acct.py b/src/handlers/acct.py index 685b021a..ec213265 100644 --- a/src/handlers/acct.py +++ b/src/handlers/acct.py @@ -47,6 +47,7 @@ async def get(self, acct_id): isadmin = self.acct.is_kernel() rate_data['rate'] = math.floor(rate_data['rate']) + rate_data['ac_pro_cnt'] = sum(t.get('rate') == 100 for t in ratemap.values()) # force https, add by xiplus, 2018/8/24 acct.photo = re.sub(r'^http://', 'https://', acct.photo) @@ -54,6 +55,18 @@ async def get(self, acct_id): await self.render('acct', acct=acct, rate=rate_data, prolist=prolist2, isadmin=isadmin) + +class AcctConfigHandler(RequestHandler): + @reqenv + async def get(self, acct_id): + acct_id = int(acct_id) + err, acct = await UserService.inst.info_acct(acct_id) + if err: + self.error(err) + return + + await self.render('acct-config', acct=acct, isadmin=self.acct.is_kernel()) + @reqenv @require_permission([UserConst.ACCTTYPE_USER, UserConst.ACCTTYPE_KERNEL]) async def post(self): @@ -63,10 +76,13 @@ async def post(self): name = self.get_argument('name') photo = self.get_argument('photo') cover = self.get_argument('cover') + acct_id = self.get_argument('acct_id') - err, _ = await UserService.inst.update_acct( - self.acct.acct_id, self.acct.acct_type, self.acct.acct_class, name, photo, cover - ) + if acct_id != str(self.acct.acct_id): + self.error('Eacces') + return + + err, _ = await UserService.inst.update_acct(self.acct.acct_id, self.acct.acct_type, self.acct.acct_class, name, photo, cover) if err: self.error(err) return @@ -93,7 +109,6 @@ async def post(self): self.error('Eunk') - class SignHandler(RequestHandler): @reqenv async def get(self): diff --git a/src/static/templ/acct-config.html b/src/static/templ/acct-config.html new file mode 100644 index 00000000..2e548adc --- /dev/null +++ b/src/static/templ/acct-config.html @@ -0,0 +1,171 @@ +{{ htmlgen.set_page_title("Edit Account") }} + +{% if acct.acct_id != acct_id and not isadmin %} + You don't have permission. +{% else %} + + +
+
+ +

Edit User {{ acct.name }}

+
+ + {% if acct.acct_id == acct_id %} +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+
+ {% end %} + + {% if acct.acct_id == acct_id or isadmin %} +
+

更改密碼

+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+
+ {% end %} +
+
+ +{% end %} \ No newline at end of file diff --git a/src/static/templ/acct.html b/src/static/templ/acct.html index 1402993e..c450ca1a 100644 --- a/src/static/templ/acct.html +++ b/src/static/templ/acct.html @@ -55,77 +55,8 @@