Skip to content

Commit

Permalink
Merge pull request #99 from code4romania/develop
Browse files Browse the repository at this point in the history
new version of site to master
  • Loading branch information
RaduCStefanescu authored Jun 27, 2019
2 parents cb9eab4 + da90937 commit e3d2155
Show file tree
Hide file tree
Showing 24 changed files with 7,719 additions and 115 deletions.
Binary file modified .DS_Store
Binary file not shown.
7 changes: 1 addition & 6 deletions .github/CONTRIBUTING.MD
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,7 @@ Please make sure to check out the suggested coding [best practices](#best-practi

### Git workflow

* [Fork the repo](https://github.com/code4romania/civichq-api/fork)
* Add your contributions on the `develop` branch of your fork
* Rebase on upstream `develop` if it changed
* Create a new Pull Request, clearly mentioning what issues your pull request fixes

:wink: If you need tips on working with Git, Github or contributing to open source projects, we have gathered a list of useful guides and tutorials in our knowledge base. [Have a look](https://code4romania.github.io/knowledge/#contributing-to-open-source).
Our collaboration model [is described here](WORKFLOW.md).

## About Code4Ro

Expand Down
164 changes: 164 additions & 0 deletions .github/WORKFLOW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

## Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or just head straight to the command line:

```shell
# Clone your fork to your local machine
git clone git@github.com:USERNAME/FORKED-PROJECT.git
```

## Keeping Your Fork Up to Date

While this isn't an absolutely necessary step, if you plan on doing anything more than just a tiny quick fix, you'll want to make sure you keep your fork up to date by tracking the original "upstream" repo that you forked. To do this, you'll need to add a remote:

```shell
# Add 'upstream' repo to list of remotes
git remote add upstream https://github.com/UPSTREAM-USER/ORIGINAL-PROJECT.git

# Verify the new remote named 'upstream'
git remote -v
```

Whenever you want to update your fork with the latest upstream changes, you'll need to first fetch the upstream repo's branches and latest commits to bring them into your repository:

```shell
# Fetch from upstream remote
git fetch upstream

# View all branches, including those from upstream
git branch -va
```

Now, checkout your own master branch and merge the upstream repo's master branch:

```shell
# Checkout your master branch and merge upstream
git checkout master
git merge upstream/master
```

If there are no unique commits on the local master branch, git will simply perform a fast-forward. However, if you have been making changes on master (in the vast majority of cases you probably shouldn't be - [see the next section](#doing-your-work), you may have to deal with conflicts. When doing so, be careful to respect the changes made upstream.

Now, your local master branch is up-to-date with everything modified upstream.

## Doing Your Work

### Create a Branch
Whenever you begin work on a new feature or bugfix, it's important that you create a new branch. Not only is it proper git workflow, but it also keeps your changes organized and separated from the master branch so that you can easily submit and manage multiple pull requests for every task you complete.

To create a new branch and start working on it:

```shell
# Checkout the master branch - you want your new branch to come from master
git checkout master

# Create a new branch named newfeature (give your branch its own simple informative name)
git branch newfeature

# Switch to your new branch
git checkout newfeature
```

Now, go to town hacking away and making whatever changes you want to.

## Submitting a Pull Request

### Cleaning Up Your Work

Prior to submitting your pull request, you might want to do a few things to clean up your branch and make it as simple as possible for the original repo's maintainer to test, accept, and merge your work.

If any commits have been made to the upstream master branch, you should rebase your development branch so that merging it will be a simple fast-forward that won't require any conflict resolution work.

```shell
# Fetch upstream master and merge with your repo's master branch
git fetch upstream
git checkout master
git merge upstream/master

# If there were any new commits, rebase your development branch
git checkout newfeature
git rebase master
```

Now, it may be desirable to squash some of your smaller commits down into a small number of larger more cohesive commits. You can do this with an interactive rebase:

```shell
# Rebase all commits on your development branch
git checkout
git rebase -i master
```

This will open up a text editor where you can specify which commits to squash.

### Submitting

Once you've committed and pushed all of your changes to GitHub, go to the page for your fork on GitHub, select your development branch, and click the pull request button. If you need to make any adjustments to your pull request, just push the updates to GitHub. Your pull request will automatically track the changes on your development branch and update.

## Accepting and Merging a Pull Request

Take note that unlike the previous sections which were written from the perspective of someone that created a fork and generated a pull request, this section is written from the perspective of the original repository owner who is handling an incoming pull request. Thus, where the "forker" was referring to the original repository as `upstream`, we're now looking at it as the owner of that original repository and the standard `origin` remote.

### Checking Out and Testing Pull Requests
Open up the `.git/config` file and add a new line under `[remote "origin"]`:

```
fetch = +refs/pull/*/head:refs/pull/origin/*
```

Now you can fetch and checkout any pull request so that you can test them:

```shell
# Fetch all pull request branches
git fetch origin

# Checkout out a given pull request branch based on its number
git checkout -b 999 pull/origin/999
```

Keep in mind that these branches will be read only and you won't be able to push any changes.

### Automatically Merging a Pull Request
In cases where the merge would be a simple fast-forward, you can automatically do the merge by just clicking the button on the pull request page on GitHub.

### Manually Merging a Pull Request
To do the merge manually, you'll need to checkout the target branch in the source repo, pull directly from the fork, and then merge and push.

```shell
# Checkout the branch you're merging to in the target repo
git checkout master

# Pull the development branch from the fork repo where the pull request development was done.
git pull https://github.com/forkuser/forkedrepo.git newfeature

# Merge the development branch
git merge newfeature

# Push master with the new feature merged into it
git push origin master
```

Now that you're done with the development branch, you're free to delete it.

```shell
git branch -d newfeature
```



**Copyright**

Copyright 2017, Chase Pettit

MIT License, http://www.opensource.org/licenses/mit-license.php

**Additional Reading**
* [Atlassian - Merging vs. Rebasing](https://www.atlassian.com/git/tutorials/merging-vs-rebasing)

**Sources**
* [GitHub - Fork a Repo](https://help.github.com/articles/fork-a-repo)
* [GitHub - Syncing a Fork](https://help.github.com/articles/syncing-a-fork)
* [GitHub - Checking Out a Pull Request](https://help.github.com/articles/checking-out-pull-requests-locally)
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

It is sadly common for NGOs or individuals to be working on specific civic tech projects without being aware of similar or identical initiatives. This phenomena is conducive to resource wasting in an area already plagued by a dire lack of resources.

Moreover, this lack of resources leads to projects and apps being rapidly abandoned, even when proving to be extremely useful.
Moreover, this lack of resources leads to projects and apps being rapidly abandoned, even when proving to be extremely useful.

Centru Civic 1.0 is already online and has begun by listing over 30 civic apps developed in Romania. Currently, the apps suite is split in categories and each application has a dedicated presentation page, together with contact details and essential information. The platform allows NGOs to add their own apps as long as they fit simple criteria such as: opensource code, updated content and lack of any political affiliation.

Expand All @@ -25,6 +25,8 @@ This repo holds the API of Centru Civic.

This project is built by amazing volunteers and you can be one of them! Here's a list of ways in [which you can contribute to this project](.github/CONTRIBUTING.MD).

If your changes involve updates in the DB please update the database/InitializeDB.sql scrips and also create a new incremental script in the database/incremental-scripts folder.

## Built With

### Programming languages
Expand All @@ -41,7 +43,7 @@ mysql

## Repos and projects

Related to https://github.com/code4romania/civichq-client
Related to https://github.com/code4romania/civichq-client

## Deployment

Expand All @@ -63,6 +65,14 @@ pm2 logs
pm2 list
```

### Docs

API docs with Swagger will be available at: http://localhost:8080/explorer

### Testing

If you want to test your API calls with [Postman](https://www.getpostman.com/), we have included an export of the postman collection. You can find it here: /testing/Centru civic.postman_collection.json . Any updates to it and automated postman tests are highly appreciated.

## Feedback

* Request a new feature on GitHub.
Expand Down
14 changes: 10 additions & 4 deletions api/add-app-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function AddAppApi(
appcreationdate,
applogo,
apptags,
apptechnologies,
ngoname,
ngophone,
ngoemail,
Expand All @@ -17,7 +18,8 @@ function AddAppApi(
ngotwitter,
ngoinstagram,
ngodescription,
ngologo
ngologo,
isActive
){
this.appname = appname;
this.categoryid = categoryid;
Expand All @@ -28,6 +30,7 @@ function AddAppApi(
this.appcreationdate = appcreationdate;
this.applogo = applogo;
this.apptags = apptags;
this.apptechnologies = apptechnologies;
this.ngoname = ngoname;
this.ngophone = ngophone;
this.ngoemail = ngoemail;
Expand All @@ -38,14 +41,15 @@ function AddAppApi(
this.ngoinstagram = ngoinstagram;
this.ngodescription = ngodescription;
this.ngologo = ngologo;
this.isActive = isActive;

}

AddAppApi.prototype = {

AddApp: function(res, seq){

seq.query('CALL AddApp (:apname , :categoryid , :appwebsite , :appfacebook , :appgithub , :appdescription , :appcreationdate , :applogo , :apptags , :ngname , :ngophone , :ngoemail , :ngofacebook , :ngogoogleplus , :ngolinkedin , :ngotwitter , :ngoinstagram , :ngodescription , :ngologo );', {replacements: {
seq.query('CALL AddApp (:apname , :categoryid , :appwebsite , :appfacebook , :appgithub , :appdescription , :appcreationdate , :applogo , :apptags , :apptechnologies , :ngname , :ngophone , :ngoemail , :ngofacebook , :ngogoogleplus , :ngolinkedin , :ngotwitter , :ngoinstagram , :ngodescription , :ngologo, :appisactive );', {replacements: {
apname: this.appname,
categoryid: this.categoryid,
appwebsite: this.appwebsite || null,
Expand All @@ -55,6 +59,7 @@ AddAppApi.prototype = {
appcreationdate: this.appcreationdate || null,
applogo: this.applogo || null,
apptags: this.apptags || null,
apptechnologies: this.apptechnologies || null,
ngname: this.ngoname,
ngophone: this.ngophone || null,
ngoemail: this.ngoemail,
Expand All @@ -64,7 +69,8 @@ AddAppApi.prototype = {
ngotwitter: this.ngotwitter || null,
ngoinstagram: this.ngoinstagram || null,
ngodescription: this.ngodescription || null,
ngologo: this.ngologo || null
ngologo: this.ngologo || null,
appisactive: this.isActive === true ? 1 : 0
}}).then(function(r){
res.send(r[0]);
}).catch(function(err){
Expand All @@ -76,4 +82,4 @@ AddAppApi.prototype = {
}


module.exports = AddAppApi;
module.exports = AddAppApi;
43 changes: 42 additions & 1 deletion api/approve-api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var BaseAppQuery = require('./base-app-query');
var ResponseFormatter = require('./response-formatter');

function ApproveApi() {

Expand Down Expand Up @@ -31,7 +32,7 @@ ApproveApi.prototype = {

var p1 = seq.query(query,
{
replacements: {appId: appId },
replacements: { appId: appId },
type: seq.QueryTypes.UPDATE
}
)
Expand All @@ -45,6 +46,46 @@ ApproveApi.prototype = {
});
});

},

EditApp: function (res, seq, reqBody, logoSavePath, isDebug) {
var resp = new ResponseFormatter(isDebug);
console.log(JSON.stringify(reqBody, null, 4));
seq.query('CALL EditApp (:appid, :apname , :categoryid , :appwebsite , :appfacebook , :appgithub , :appdescription , :apptechnologies , :appcreationdate , :applogo , :apptags , :ngname , :ngophone , :ngoemail , :ngofacebook , :ngogoogleplus , :ngolinkedin , :ngotwitter , :ngoinstagram , :ngodescription , :ngologo, :ngoid, :appisactive );', {
replacements: {
appid: reqBody.appid,
apname: reqBody.appname,
categoryid: reqBody.appcategoryid,
appwebsite: reqBody.appwebsite || null,
appfacebook: reqBody.appfacebook || null,
appgithub: reqBody.appgithub || null,
appdescription: reqBody.appdescription || null,
apptechnologies: reqBody.apptechnologies || null,
appcreationdate: reqBody.appcreationdate || null,
applogo: logoSavePath + reqBody.applogoname || null,
apptags: reqBody.apphashtags || null,
ngname: reqBody.ngoname,
ngophone: reqBody.ngophone || null,
ngoemail: reqBody.ngoemail,
ngofacebook: reqBody.ngofacebook || null,
ngogoogleplus: reqBody.ngogoogleplus || null,
ngolinkedin: reqBody.ngolinkedin || null,
ngotwitter: reqBody.ngotwitter || null,
ngoinstagram: reqBody.ngoinstagram || null,
ngodescription: reqBody.ngodescription || null,
ngologo: logoSavePath + reqBody.ngologoname || null,
ngoid: reqBody.ngoid,
appisactive: reqBody.isActive === true ? 1 : 0
}
}).then(function (rez) {
resp.FormatFromResult(res, rez[0].result);

})
.catch(
function (err) {
res.send(resp.FormatError(err));
}
);
}

}
Expand Down
5 changes: 4 additions & 1 deletion api/base-app-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ function BaseAppQuery() {
'c.Id as \'appdetail.categoryid\',' +
'c.CatName as \'appdetail.categoryname\',' +
'a.tags as \'appdetail.hashtags\',' +
'a.technologies as \'appdetail.technologies\',' +
'a.github as \'appdetail.github\',' +
'case when a.IsApproved = 1 then \'true\' else \'false\' end AS \'appdetail.isapproved\',' +
'case when a.IsActive = 1 then \'true\' else \'false\' end AS \'appdetail.isactive\',' +
'n.Id as \'ngodetail.id\',' +
'n.NgoName as \'ngodetail.name\',' +
'n.phone as \'ngodetail.phone\',' +
'n.email as \'ngodetail.email\',' +
Expand All @@ -36,4 +39,4 @@ BaseAppQuery.prototype = {
}
}

module.exports = BaseAppQuery;
module.exports = BaseAppQuery;
Loading

0 comments on commit e3d2155

Please sign in to comment.