src/templates/people/sip.html \
src/templates/people/subscribed.html \
src/templates/people/unsubscribe.html \
- src/templates/people/unsubscribed.html \
- src/templates/people/user-edit.html
+ src/templates/people/unsubscribed.html
templates_peopledir = $(templatesdir)/people
templates_staticdir = $(templatesdir)/static
templates_users_DATA = \
+ src/templates/users/edit.html \
src/templates/users/index.html \
src/templates/users/passwd.html \
src/templates/users/show.html
(r"/users", users.IndexHandler),
(r"/users/([a-z_][a-z0-9_-]{0,31})", users.ShowHandler),
(r"/users/([a-z_][a-z0-9_-]{0,31})\.jpg", users.AvatarHandler),
+ (r"/users/([a-z_][a-z0-9_-]{0,31})/edit", users.EditHandler),
(r"/users/([a-z_][a-z0-9_-]{0,31})/passwd", users.PasswdHandler),
# Static Pages
(r"/register", auth.RegisterHandler),
(r"/users/([a-z_][a-z0-9_-]{0,31})/calls/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})", people.CallHandler),
(r"/users/([a-z_][a-z0-9_-]{0,31})/calls(?:/(\d{4}-\d{2}-\d{2}))?", people.CallsHandler),
- (r"/users/([a-z_][a-z0-9_-]{0,31})/edit", people.UserEditHandler),
(r"/users/([a-z_][a-z0-9_-]{0,31})/sip", people.SIPHandler),
# Promotional Consent Stuff
import ldap
import tornado.web
-from .. import countries
-
from . import base
from . import ui_modules
self.render("people/sip.html", account=account)
-class UserEditHandler(base.BaseHandler):
- @tornado.web.authenticated
- def get(self, uid):
- account = self.backend.accounts.get_by_uid(uid)
- if not account:
- raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
-
- # Check for permissions
- if not account.can_be_managed_by(self.current_user):
- raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account))
-
- self.render("people/user-edit.html", account=account, countries=countries.get_all())
-
- @tornado.web.authenticated
- def post(self, uid):
- account = self.backend.accounts.get_by_uid(uid)
- if not account:
- raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
-
- # Check for permissions
- if not account.can_be_managed_by(self.current_user):
- raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account))
-
- # Unfortunately this cannot be wrapped into a transaction
- try:
- account.first_name = self.get_argument("first_name")
- account.last_name = self.get_argument("last_name")
- account.nickname = self.get_argument("nickname", None)
- account.street = self.get_argument("street", None)
- account.city = self.get_argument("city", None)
- account.postal_code = self.get_argument("postal_code", None)
- account.country_code = self.get_argument("country_code", None)
- account.description = self.get_argument("description", None)
-
- # Avatar
- try:
- filename, data, mimetype = self.get_file("avatar")
-
- if not mimetype.startswith("image/"):
- raise tornado.web.HTTPError(400, "Avatar is not an image file: %s" % mimetype)
-
- account.upload_avatar(data)
- except TypeError:
- pass
-
- # Email
- account.mail_routing_address = self.get_argument("mail_routing_address", None)
-
- # Telephone
- account.phone_numbers = self.get_argument("phone_numbers", "").splitlines()
- account.sip_routing_address = self.get_argument("sip_routing_address", None)
- except ldap.STRONG_AUTH_REQUIRED as e:
- raise tornado.web.HTTPError(403, "%s" % e) from e
-
- # Redirect back to user page
- self.redirect("/users/%s" % account.uid)
-
-
class AgentModule(ui_modules.UIModule):
def render(self, account):
return self.render_string("people/modules/agent.html", account=account)
import PIL
import imghdr
import io
+import ldap
import logging
import os.path
import tornado.web
+from .. import countries
+
from . import base
from . import ui_modules
return f.getvalue()
+class EditHandler(base.BaseHandler):
+ @tornado.web.authenticated
+ def get(self, uid):
+ account = self.backend.accounts.get_by_uid(uid)
+ if not account:
+ raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
+
+ # Check for permissions
+ if not account.can_be_managed_by(self.current_user):
+ raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account))
+
+ self.render("users/edit.html", account=account, countries=countries.get_all())
+
+ @tornado.web.authenticated
+ def post(self, uid):
+ account = self.backend.accounts.get_by_uid(uid)
+ if not account:
+ raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
+
+ # Check for permissions
+ if not account.can_be_managed_by(self.current_user):
+ raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account))
+
+ # Unfortunately this cannot be wrapped into a transaction
+ try:
+ account.first_name = self.get_argument("first_name")
+ account.last_name = self.get_argument("last_name")
+ account.nickname = self.get_argument("nickname", None)
+ account.street = self.get_argument("street", None)
+ account.city = self.get_argument("city", None)
+ account.postal_code = self.get_argument("postal_code", None)
+ account.country_code = self.get_argument("country_code", None)
+ account.description = self.get_argument("description", None)
+
+ # Avatar
+ try:
+ filename, data, mimetype = self.get_file("avatar")
+
+ if not mimetype.startswith("image/"):
+ raise tornado.web.HTTPError(400, "Avatar is not an image file: %s" % mimetype)
+
+ account.upload_avatar(data)
+ except TypeError:
+ pass
+
+ # Email
+ account.mail_routing_address = self.get_argument("mail_routing_address", None)
+
+ # Telephone
+ account.phone_numbers = self.get_argument("phone_numbers", "").splitlines()
+ account.sip_routing_address = self.get_argument("sip_routing_address", None)
+ except ldap.STRONG_AUTH_REQUIRED as e:
+ raise tornado.web.HTTPError(403, "%s" % e) from e
+
+ # Redirect back to user page
+ self.redirect("/users/%s" % account.uid)
+
+
class PasswdHandler(base.BaseHandler):
@tornado.web.authenticated
def get(self, uid):