Esempio n. 1
0
 def get(self, **kwargs):
     kwargs['user'] = User.get(kwargs['userid'])
     history = JobHistoryModel.all()
     history.filter("CreatedBy =", User.get(kwargs['userid']))
     history.order("-Created").fetch(20);
     kwargs['history'] = history
     return self.render_response('adminuser.html', **kwargs)
Esempio n. 2
0
class TestBaseModel(unittest.TestCase):
    #---------------------------------------------------------------------------
    def setUp(self):
        datastore_stub = apiproxy_stub_map.apiproxy._APIProxyStubMap__stub_map[
            'datastore_v3'
        ]
        datastore_stub.Clear()
        self.app = Tipfy()
        self.client = self.app.get_test_client()

        # plans
        self.plan_active = models.Plan(
            name='Plan Active',
            plan_key='ACTIVE',
            is_active=True,
            default=False
        )
        self.plan_active.put()
        self.plan_inactive = models.Plan(
            name='Plan InActive',
            plan_key='INACTIVE',
            is_active=False,
            default=False
        )
        self.plan_inactive.put()
        self.plan_default = models.Plan(
            name='Plan Default',
            plan_key='DEFAULT',
            is_active=True,
            default=True
        )
        self.plan_default.put()

        # accounts
        self.user_1 = User(
            username='******',
            password='******',
            session_id='1',
            auth_id='own|user_1'
        )
        self.user_1.put()
        self.user_2 = User(
            username='******',
            password='******',
            session_id='2',
            auth_id='own|user_2'
        )
        self.user_2.put()
        self.account_active = models.Account.get_or_insert_plan(user=self.user_1)
Esempio n. 3
0
    def get(self, user_key=None):
        '''
        Send e-mail to user ordered a delivery and the admin
        '''
        user = User.get(user_key)
        profile = Profile.all().filter('user ='******'already verified')
        
        context = {
            'user': user,
            'profile': profile,
        }
        
        body = render_template('mail/verify.html', **context)
        message = mail.EmailMessage()

        message.to = user.email
        message.body = body
        message.subject = SUBJECT_REGISTRATION
        message.sender = SENDER
        message.reply_to = REPLY_TO
        message.send()
        return Response(body)
Esempio n. 4
0
 def post(self, **kwargs):
     userid = self.request.form.get('userid')
     user = User.get(userid)
     user.disabled = not user.disabled
     user.put()
     self.set_message('success', 'The users account was successfully changed. ', flash=True, life=5)
     return redirect_to('home')
Esempio n. 5
0
    def get(self, user_key=None):
        '''
        Send e-mail to user ordered a delivery and the admin
        '''
        user = User.get(user_key)
        profile = Profile.all().filter('user ='******'already verified')

        context = {
            'user': user,
            'profile': profile,
        }

        body = render_template('mail/verify.html', **context)
        message = mail.EmailMessage()

        message.to = user.email
        message.body = body
        message.subject = SUBJECT_REGISTRATION
        message.sender = SENDER
        message.reply_to = REPLY_TO
        message.send()
        return Response(body)
Esempio n. 6
0
def add_history(description, user, jobid=None, clientid=None, userid=None):
    jhm = JobHistoryModel()
    jhm.Description = description
    jhm.CreatedBy = user
    if jobid:
        jhm.Job = JobModel.get(jobid)
    if clientid: 
        jhm.Client = ClientModel.get(clientid)
    if userid:
        jhm.User = User.get(userid)
    jhm.put()
Esempio n. 7
0
 def get(self,  **kwargs):
     if str(self.auth_current_user.key()) == kwargs['userid'] or self.auth_current_user.is_admin or self.auth_current_user.is_staff:
         form = self.form
         user = User.get(kwargs['userid'])
         kwargs['user'] = user
         history = JobHistoryModel.all()
         history.filter("CreatedBy =", User.get(kwargs['userid']))
         history.order("-Created").fetch(20);
         kwargs['history'] = history
         if user.assigned_to:
             kwargs['client'] = ClientModel.get(user.assigned_to) 
         if user: 
             obj = { 'username' : user.username, 'key' : str(user.key()), 'email' : user.email }
             logging.log(logging.INFO, 'editing user: '******'form'] = form
             
         return self.render_response('edituser.html', **kwargs)
     else:
         return self.redirect_to(url_for('account/login'))
Esempio n. 8
0
    def get(self, username='', **kwargs):
        current_user = self.auth_current_user

        if current_user != None and current_user.username == username:
            context = {
                'user': current_user,
            }
            return self.render_response('auth/me.html', **context)

        user = User.get_by_username(username)

        if user is None:
            self.abort(404)

        context = {
            'user': user,
        }

        return self.render_response('auth/user.html', **context)
Esempio n. 9
0
 def post(self, **kwargs):
     if str(self.auth_current_user.key()) == kwargs['userid'] or self.auth_current_user.is_admin or self.auth_current_user.is_staff:
         username = self.form.username.data
         email = self.form.email.data
         password = self.form.password.data
         password_confirm = self.form.password_confirm.data
         if password != password_confirm:
             self.set_message('error', "Password confirmation didn't match.", life = None)
             return self.get(**kwargs)
         olduser = User.get(kwargs['userid'])
         olduser.email = email
         if password is not None and len(password) > 0:
             olduser.set_password(password)
             self.set_message('success', 'The users password was changed. ', flash=True, life=5)
             add_history("user password was changed", self.auth_current_user, None, olduser.assigned_to, olduser.key())
         olduser.put()
         add_history("user was modified", self.auth_current_user, None, olduser.assigned_to, olduser.key())
         self.set_message('success', 'The user was successfully updated. ', flash=True, life=5)
         return self.get(**kwargs)
     else:
         return self.redirect_to(url_for('auth/login'))
Esempio n. 10
0
File: models.py Progetto: ac001/moe
 def editor(self):
     if self.editor_key:
         return User.get(db.Key(self.editor_key))
Esempio n. 11
0
File: models.py Progetto: ac001/moe
 def author(self):
     if self.author_key:
         return User.get(db.Key(self.author_key))