// ProjectHome returns a slice of ProjectPost selected by options
511901
func (user *User) ProjectHome(options PostlistOptions) *[]ProjectPost {
	var projectPost ProjectPost

	query := Db().Model(projectPost).Order("hpid DESC")
	query = projectPostlistConditions(query, user)

	options.Model = projectPost
	query = postlistQueryBuilder(query, options, user)

	var projectPosts []ProjectPost
	query.Scan(&projectPosts)

	return &projectPosts
}
952838
func ProjectConfig(p project.APIProject, c *cli.Context) error {
	yaml, err := p.Config()
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	if !c.Bool("quiet") {
		fmt.Println(yaml)
	}
	return nil
}
1018857
func WithHome(path string) func(*icmd.Cmd) {
	return func(cmd *icmd.Cmd) {
		cmd.Env = append(cmd.Env, "HOME="+path)
	}
}
984355
func (s *Service) ProjectConfig(c context.Context, proj types.ProjectName) (*svcconfig.ProjectConfig, error) {
	cset, path := s.ProjectConfigPath(proj)

	var pcfg svcconfig.ProjectConfig
	msg, err := s.configCache.Get(c, cset, path, &pcfg)
	if err != nil {
		return nil, errors.Annotate(err, "failed to load project config from %s.%s", cset, path).Err()
	}
	return msg.(*svcconfig.ProjectConfig), nil
}
1063803
func deleteProject(c context.Context, projectId string) error {
	return datastore.RunInTransaction(c, func(c context.Context) error {
		project := &Project{Name: projectId}
		ancestorKey := datastore.KeyForObj(c, project)
		return parallel.FanOutIn(func(work chan<- func() error) {
			work <- func() error {
				return removeDescendants(c, "Builder", ancestorKey, nil)
			}
			work <- func() error {
				return removeDescendants(c, "EmailTemplate", ancestorKey, nil)
			}
			work <- func() error {
				return datastore.Delete(c, project)
			}
		})
	}, nil)
}
681033
func (c *projects) List(opts v1.ListOptions) (result *project.ProjectList, err error) {
	var timeout time.Duration
	if opts.TimeoutSeconds != nil {
		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
	}
	result = &project.ProjectList{}
	err = c.client.Get().
		Resource("projects").
		VersionedParams(&opts, scheme.ParameterCodec).
		Timeout(timeout).
		Do().
		Into(result)
	return
}
231767
func (prj *Project) Postlist(options PostlistOptions) *[]ExistingPost {
	var posts []ProjectPost
	var projectPost ProjectPost
	projectPosts := projectPost.TableName()
	users := new(User).TableName()

	query := Db().Model(projectPost).Order("hpid DESC").
		Joins("JOIN "+users+" ON "+users+".counter = "+projectPosts+".to"). //PostListOptions.Language support
		Where(`"to" = ?`, prj.ID())

	options.Model = projectPost
	query = postlistQueryBuilder(query, options)
	query.Scan(&posts)

	var retPosts []ExistingPost
	for _, p := range posts {
		projectPost := p
		retPosts = append(retPosts, ExistingPost(&projectPost))
	}

	return &retPosts
}
1288131
func (exp *explorerUI) NextHome(w http.ResponseWriter, r *http.Request) {
	// Get top N blocks and trim each block to have just the fields required for
	// this page.
	height, err := exp.blockData.GetHeight()
	if err != nil {
		log.Errorf("GetHeight failed: %v", err)
		exp.StatusPage(w, defaultErrorCode, defaultErrorMessage, "",
			ExpStatusError)
		return
	}
	blocks := exp.blockData.GetExplorerFullBlocks(int(height),
		int(height)-homePageBlocksMaxCount)

	// trim unwanted data in each block
	trimmedBlocks := make([]*types.TrimmedBlockInfo, 0, len(blocks))
	for _, block := range blocks {
		trimmedBlock := &types.TrimmedBlockInfo{
			Time:         block.BlockTime,
			Height:       block.Height,
			Total:        block.TotalSent,
			Fees:         block.MiningFee,
			Subsidy:      block.Subsidy,
			Votes:        block.Votes,
			Tickets:      block.Tickets,
			Revocations:  block.Revs,
			Transactions: types.FilterRegularTx(block.Tx),
		}

		trimmedBlocks = append(trimmedBlocks, trimmedBlock)
	}

	// Construct the required TrimmedMempoolInfo from the shared inventory.
	inv := exp.MempoolInventory()
	mempoolInfo := inv.Trim() // Trim internally locks the MempoolInfo.

	exp.pageData.RLock()
	mempoolInfo.Subsidy = exp.pageData.HomeInfo.NBlockSubsidy

	str, err := exp.templates.execTemplateToString("nexthome", struct {
		*CommonPageData
		Info    *types.HomeInfo
		Mempool *types.TrimmedMempoolInfo
		Blocks  []*types.TrimmedBlockInfo
	}{
		CommonPageData: exp.commonData(r),
		Info:           exp.pageData.HomeInfo,
		Mempool:        mempoolInfo,
		Blocks:         trimmedBlocks,
	})

	exp.pageData.RUnlock()

	if err != nil {
		log.Errorf("Template execute failure: %v", err)
		exp.StatusPage(w, defaultErrorCode, defaultErrorMessage, "", ExpStatusError)
		return
	}
	w.Header().Set("Content-Type", "text/html")
	w.WriteHeader(http.StatusOK)
	io.WriteString(w, str)
}
475201
func ProjectID(id string) broker.Option {
	return func(o *broker.Options) {
		if o.Context == nil {
			o.Context = context.Background()
		}
		o.Context = context.WithValue(o.Context, projectIDKey{}, id)
	}
}
605402
func AddProject(project Project) error {
	o := orm.NewOrm()

	_, err := o.Insert(&project)

	return err
}
1091607
func NewProjectWhere(description *Project) (project *Project, e error) {
	project = new(Project)
	if e = Db().Where(description).Scan(project); e != nil {
		return
	}
	return
}
873130
func (c *Client) DeleteProject(projectName string) (result ResultModel, err error) {

	requestUrl := c.GetUrl("projects", "", projectName)
	requestPath := GetRequestPath("projects", "", projectName)

	responseResult, err := c.GetResponseJson("DELETE", requestUrl, requestPath, "")

	if err != nil {
		return result, err
	}

	err = json.Unmarshal([]byte(responseResult), &result)

	return result, err

}
528686
func (c *ApiController) GetProject() {
	log.Info("Get project")

	projectId, _ := c.GetInt64(":projectId")
	project := models.GetProjectWithId(projectId)

	c.Data["json"] = project
	c.ServeJson()
}
793351
func Convert_v1_ProjectSpec_To_project_ProjectSpec(in *v1.ProjectSpec, out *project.ProjectSpec, s conversion.Scope) error {
	return autoConvert_v1_ProjectSpec_To_project_ProjectSpec(in, out, s)
}
977028
func (s *ProjectService) GetProjectID(name string, opts ...OptionFunc) (string, int, error) {
	p := &ListProjectsParams{}
	p.p = make(map[string]interface{})

	p.p["name"] = name

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return "", -1, err
		}
	}

	l, err := s.ListProjects(p)
	if err != nil {
		return "", -1, err
	}

	if l.Count == 0 {
		return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
	}

	if l.Count == 1 {
		return l.Projects[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.Projects {
			if v.Name == name {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
}
642218
func ProjectPs(p project.APIProject, c *cli.Context) error {
	qFlag := c.Bool("q")
	allInfo, err := p.Ps(context.Background(), c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	columns := []string{"Name", "Command", "State", "Ports"}
	if qFlag {
		columns = []string{"Id"}
	}
	os.Stdout.WriteString(allInfo.String(columns, !qFlag))
	return nil
}
1224612
func (p *ProjectCard) GetProjectURL() string {
	if p == nil || p.ProjectURL == nil {
		return ""
	}
	return *p.ProjectURL
}