Exemplo n.º 1
0
 def inviteusers_POST(self):
     """
     admin is sending out a number of invites to users
     """
     if 'emails' in request.POST:
         emails = request.POST['emails']
         delay = 4
         from demisauce.lib import scheduler
         for email in emails.split(','):
             email = email.strip().lower()
             user = Person.by_email(c.user.site_id,email)
             
             if user is None:
                 user = Person(site_id=c.site_id,email=email, displayname=email)
                 user.save()
                 #send emails
                 url2 = urllib.quote_plus('/account/viewh/%s' % (user.hashedemail))
                 dnew = {}
                 dnew['link'] = '%s/account/verify?unique=%s&node=%s&return_url=%s' %\
                     (base_url(),user.user_uniqueid,user.id,url2)
                 dnew['from'] = c.user.displayname
                 a = Activity(site_id=user.site_id,person_id=user.id,activity='sending email invite')
                 a.ref_url = 'account admin invite'
                 a.category = 'account'
                 a.save()
                 scheduler.add_interval_task(send_emails,0,('invitation_to_demisauce',[user.email],dnew) , initialdelay=delay)
                 delay += 3
             
         return 'from form %s' % emails
     return 'error'
Exemplo n.º 2
0
 def view(self,id=0):
     if not c.user:
         redirect_to(controller='home', action='index', id=None)
     
     if c.user.issysadmin and id > 0:
         person = Person.get(-1,id)
     elif id > 0: 
         person = Person.get(c.user.site_id,id)
     
     return self._view(person,True)
Exemplo n.º 3
0
def get_current_user():
    """get current user"""
    user = None
    if 'user' in session and type(session['user']) == Person:
        user = session['user']
    elif 'dsu' in request.cookies:
        user = Person.by_unique(request.cookies['userkey'].lower())
    elif 'userkey' in request.cookies:
        user = Person.by_unique(request.cookies['userkey'].lower())
    return user
Exemplo n.º 4
0
 def edit_POST(self,id = 0):
     """
     User has selected to change site config info
     """
     if 'objectid' in request.params:
         site = Site.get(-1,request.params['objectid'])
         
         if site is None:
             h.add_error("We experienced an error, please try again")
             
         else:
             site.name = self.form_result['name']
             site.description = self.form_result['description']
             site.email = self.form_result['email']
             site.slug = self.form_result['real_permalink']
             # TODO, check uniqueness
             site.public = bool(self.form_result['public'])
             site.base_url = self.form_result['base_url']
             site.site_url = self.form_result['site_url']
             site.save()
             
             # refresh session store
             user = Person.get(c.user.site_id,c.user.id)
             self.start_session(user)
             h.add_alert("Site settings were updated")
             
         
     else:
         h.add_error("There was an Error")
     
     return redirect_wsave('/site/view')
Exemplo n.º 5
0
 def interest(self):
     """
     User has selected to enter an email to be on waitinglist
     """
     if 'email' in request.POST:
         user = meta.DBSession.query(Person).filter_by(
                 email=request.POST['email'].lower()).first()
         
         if user is None:
             site = Site(name=self.form_result['email'],email=self.form_result['email'])
             site.save()
             user = Person(site_id=site.id,email=self.form_result['email'],
                           displayname=self.form_result['email'])
             user.slug = user.hashedemail
             user.save()
             a = Activity(site_id=user.site_id,person_id=user.id,activity='Signup Interest Form')
             #a.ref_url = 'comment url'
             a.category = 'account'
             a.save()
             #TODO:  refactor/extract email send to trigger event api
             #send emails
             url2 = urllib.quote_plus('/account/viewh/%s' % (user.hashedemail))
             delay = 4
             from demisauce.lib import scheduler
             dnew = {}
             dnew['link'] = '%s/account/verify?unique=%s&node=%s&return_url=%s' %\
                 (c.base_url,user.user_uniqueid,user.id,url2)
             dnew['displayname'] = user.displayname
             dnew['email'] = user.email
             dnew['title'] = 'welcome'
             scheduler.add_interval_task(send_emails,0,('thank_you_for_registering_with_demisauce',
                 [user.email],dnew) , initialdelay=delay)
             if 'demisauce.admin' in config:
                 scheduler.add_interval_task(send_emails,0,('a-new-user-has-registered',
                     [config['demisauce.admin']],dnew) , initialdelay=8)
         
         h.add_alert("Thank You!")
         return redirect_wsave(controller='home',action='index')
     
     else:
         h.add_error("You need to enter an email.")
     
     return render('/account/signup.html')
Exemplo n.º 6
0
 def get_user(self):
     '''grabs person record for submitter'''
     if self.person_id and self.person_id > 0:
         if not hasattr(self,'_person'):
             temp = Person.get(-1,self.person_id)
             if temp:
                 self._person = temp
             else:
                 self._person = None
     return self._person
Exemplo n.º 7
0
 def account_edit(self):
     """
     User has selected to update profile
     """
     if c.user and 'email' in request.POST:
         user = Person.get(c.user.site_id,c.user.id)
         user.displayname = request.POST['displayname']
         user.set_email(request.POST['email'])
         user.url = request.POST['url']
         self.start_session(user)
         user.save()
         c.person = user
         c.user = user
         self.start_session(user)
     return render('/account/settings.html')
Exemplo n.º 8
0
 def view_mini(self,id=0):
     c.person = None
     if id > 0: # authenticated user
         person = Person.get(c.user.site_id,id)
         c.person = person
     return render('/account/profile_mini.html')