Beispiel #1
0
 def post(self, *a, **kw):
     errors = _h.get_validation_errors()
     group = _h.get_group_by_name(kw.get('group_name', None))
     all_p = DBSession.query(Project).all()
     if not group:
         errors['group'] = 'Group does not exist!'
         
     s = Site()
     s.label = unicode(re.sub(' ', '_', kw['label']).lower())
     s.display_name = unicode(kw.get('display_name', None))
     s.desc = kw.get('desc', None)
     s.url = unicode(kw.get('url', None))
     s.contact_name = unicode(kw.get('contact_name', None))
     s.contact_email = unicode(kw.get('contact_email', None))
     s.sync_base_path = unicode(kw.get('sync_base_path', None))
     s.user = request.identity['user']
     s.group = group
 
     if len(errors) > 0:
         all_projects = [x for x in all_p if x not in s.projects]
         all_hosts = [x for x in request.identity['user'].hosts \
                         if x not in s.hosts]
         transaction.doom()
         return dict(page='site', errors=errors, site=s, 
                     all_projects=all_projects, all_hosts=all_hosts)
         
     DBSession.add(s)
     transaction.commit()
     flash(_("%s created successfully!" % kw['display_name']), 'info')
     redirect(url('/dashboard'))
Beispiel #2
0
 def post(self, *a, **kw):
     errors = _h.get_validation_errors()
     project = _h.get_project_by_name(kw.get('project_label', None))
     if not project:
         errors['project'] = "Project does not exist"
     
     _h.protect_obj_modify(project)
         
     _existing_p = _h.get_product_by_name(kw.get('label', None))
     if _existing_p:
         errors['label'] = "%s already exists!" % kw.get('label', None)
         
     p = Product()
     p.label = unicode(re.sub(' ', '_', kw['label']).lower())
     p.display_name = unicode(kw.get('display_name', None))
     p.desc = kw.get('desc', None)
     
     if len(errors) > 0:
         return dict(errors=errors, project=project, product=p)
         
     p.project = project
     
     DBSession.add(p)
     transaction.commit()
     flash(_("%s created successfully!" % kw['display_name']), 'info')
     redirect(url('/product/new?project=%s' % kw['project_label']))
Beispiel #3
0
 def post(self, *a, **kw):
     errors = _h.get_validation_errors()
     group = _h.get_group_by_name(kw.get('group_name', None))
     protocol = _h.get_protocol_by_name(kw.get('sync_protocol', None))
     all_protocols = DBSession.query(SyncProtocol).all()
     
     if not group:
         errors['group'] = 'Group does not exist!'
     if not protocol:
         errors['sync_protocol'] = 'Sync Protocol does not exist!'
         
     p = Project()
     p.label = unicode(re.sub(' ', '_', kw['label']).lower())
     _label = p.label
     p.display_name = unicode(kw.get('display_name', None))
     p.desc = kw.get('desc', None)
     p.url = unicode(kw.get('url', None))
     p.user = request.identity['user']
     p.sync_base_path = unicode(kw.get('sync_base_path', None))
     p.sync_flags = unicode(kw.get('sync_flags', None))
     p.group = group
     p.sync_protocol = protocol
     
     if len(errors) > 0:
         transaction.doom()
         return dict(page="project", errors=errors, project=p,
                     all_protocols=all_protocols)
     DBSession.add(p)
     transaction.commit()
     flash(_("%s created successfully!" % kw['display_name']), 'info')
     redirect(url('/project/%s/edit' % _label))
Beispiel #4
0
 def setup(self):
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise
Beispiel #5
0
 def _add_site_sync_path(self, site_id, project_id, sync_path):
     s = DBSession.query(Site).filter_by(id=site_id).first()
     p = DBSession.query(Project).filter_by(id=project_id).first()
     alt = DBSession.query(SiteSyncPath).filter_by(site_id=s.id)\
           .filter_by(project_id=p.id).first()
     if alt:
         alt.sync_path = sync_path
         transaction.commit()
         return alt
 
     alt = SiteSyncPath()
     alt.site = s
     alt.project = p
     alt.sync_path = sync_path
     DBSession.add(alt)
     transaction.commit()
     return alt
Beispiel #6
0
 def post(self, *a, **kw):
     errors = _h.get_validation_errors()
     product = _h.get_product_by_name(kw.get('product_label', None))
     allarchs = DBSession.query(Arch).all()
     if not product:
         raise HTTPNotFound
     _product_label = product.label
     
     _h.protect_obj_modify(product.project)
     
     r = ProductRelease()
     
     _existing_r = _h.get_release_by_name(kw.get('label', None))
     if _existing_r:
         errors['label'] = "%s already exists!" % kw.get('label', None)
     
     if len(errors) > 0:
         transaction.doom()
         return dict(errors=errors, project=product.project, 
                     all_archs=allarchs, product=product, release=r)
     
     r.product = product
     r.label = unicode(re.sub(' ', '_', kw['label']).lower())
     r.display_name = unicode(kw.get('display_name', None))
     r.desc = kw.get('desc', None)
     r.path = unicode(kw.get('path', ''))
         
     if not kw.get('archs'):
         errors['archs'] = "Must select atleast one arch"
     else:
         for a in allarchs:
             if _(a.id) in kw['archs']:
                 r.archs.append(a)
             else:
                 if a in r.archs:
                     r.archs.remove(a)
                     
     # FIX ME: Add check to make sure the rsync path is valid
     
     DBSession.add(r)
     transaction.commit()
     flash(_("%s created successfully!" % kw['display_name']), 'info')
     redirect(url('/product_release/new?product=%s' % _product_label))
Beispiel #7
0
 def post(self, **kw):
     if config['user_registration'] == 'closed':
         abort(500)
         
     errors = _h.get_validation_errors()
                   
     u = model.User()
     u.user_name = unicode(re.sub(' ', '_', kw['user_name']).lower())
     u.display_name = unicode(kw['display_name'])
     u.web_url = unicode(kw['web_url'])
     u.email_address = unicode(kw['email_address'])
     u.about = kw['about']
     u.agreed_to_terms = int(1)
     u.status = _h.status_by_name('PendingEmailVerification')
     u.password = kw['password']
     
     # add to the everyone group
     everyone = _h.group_by_name('dmirr_everyone')
     everyone.users.append(u)     
     
     msg = turbomail.Message(
         config['from_email'],
         u.email_address,
         "dMirr Email Verification"
         )
     u.verify_code = _h.gen_verification_code()
     _url = "%s/user/true_up?u=%s&vc=%s" % (config['base_url'], 
                                           u.user_name, u.verify_code)
     msg.plain = EMAIL_VERIFICATION_MSG % \
                 (u.display_name, _url, config['base_url'])
     
     db.add(u)
     transaction.commit()
     msg.send()
     flash(_('%s registration started, check email to complete.' \
             % kw['display_name']), 'info')
     redirect(url('/'))