Skip to content

Commit e3d2155

Browse files
Merge pull request #99 from code4romania/develop
new version of site to master
2 parents cb9eab4 + da90937 commit e3d2155

24 files changed

+7719
-115
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.github/CONTRIBUTING.MD

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,7 @@ Please make sure to check out the suggested coding [best practices](#best-practi
5858

5959
### Git workflow
6060

61-
* [Fork the repo](https://github.com/code4romania/civichq-api/fork)
62-
* Add your contributions on the `develop` branch of your fork
63-
* Rebase on upstream `develop` if it changed
64-
* Create a new Pull Request, clearly mentioning what issues your pull request fixes
65-
66-
: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).
61+
Our collaboration model [is described here](WORKFLOW.md).
6762

6863
## About Code4Ro
6964

.github/WORKFLOW.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
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.
2+
3+
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.
4+
5+
## Creating a Fork
6+
7+
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:
8+
9+
```shell
10+
# Clone your fork to your local machine
11+
git clone git@github.com:USERNAME/FORKED-PROJECT.git
12+
```
13+
14+
## Keeping Your Fork Up to Date
15+
16+
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:
17+
18+
```shell
19+
# Add 'upstream' repo to list of remotes
20+
git remote add upstream https://github.com/UPSTREAM-USER/ORIGINAL-PROJECT.git
21+
22+
# Verify the new remote named 'upstream'
23+
git remote -v
24+
```
25+
26+
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:
27+
28+
```shell
29+
# Fetch from upstream remote
30+
git fetch upstream
31+
32+
# View all branches, including those from upstream
33+
git branch -va
34+
```
35+
36+
Now, checkout your own master branch and merge the upstream repo's master branch:
37+
38+
```shell
39+
# Checkout your master branch and merge upstream
40+
git checkout master
41+
git merge upstream/master
42+
```
43+
44+
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.
45+
46+
Now, your local master branch is up-to-date with everything modified upstream.
47+
48+
## Doing Your Work
49+
50+
### Create a Branch
51+
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.
52+
53+
To create a new branch and start working on it:
54+
55+
```shell
56+
# Checkout the master branch - you want your new branch to come from master
57+
git checkout master
58+
59+
# Create a new branch named newfeature (give your branch its own simple informative name)
60+
git branch newfeature
61+
62+
# Switch to your new branch
63+
git checkout newfeature
64+
```
65+
66+
Now, go to town hacking away and making whatever changes you want to.
67+
68+
## Submitting a Pull Request
69+
70+
### Cleaning Up Your Work
71+
72+
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.
73+
74+
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.
75+
76+
```shell
77+
# Fetch upstream master and merge with your repo's master branch
78+
git fetch upstream
79+
git checkout master
80+
git merge upstream/master
81+
82+
# If there were any new commits, rebase your development branch
83+
git checkout newfeature
84+
git rebase master
85+
```
86+
87+
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:
88+
89+
```shell
90+
# Rebase all commits on your development branch
91+
git checkout
92+
git rebase -i master
93+
```
94+
95+
This will open up a text editor where you can specify which commits to squash.
96+
97+
### Submitting
98+
99+
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.
100+
101+
## Accepting and Merging a Pull Request
102+
103+
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.
104+
105+
### Checking Out and Testing Pull Requests
106+
Open up the `.git/config` file and add a new line under `[remote "origin"]`:
107+
108+
```
109+
fetch = +refs/pull/*/head:refs/pull/origin/*
110+
```
111+
112+
Now you can fetch and checkout any pull request so that you can test them:
113+
114+
```shell
115+
# Fetch all pull request branches
116+
git fetch origin
117+
118+
# Checkout out a given pull request branch based on its number
119+
git checkout -b 999 pull/origin/999
120+
```
121+
122+
Keep in mind that these branches will be read only and you won't be able to push any changes.
123+
124+
### Automatically Merging a Pull Request
125+
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.
126+
127+
### Manually Merging a Pull Request
128+
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.
129+
130+
```shell
131+
# Checkout the branch you're merging to in the target repo
132+
git checkout master
133+
134+
# Pull the development branch from the fork repo where the pull request development was done.
135+
git pull https://github.com/forkuser/forkedrepo.git newfeature
136+
137+
# Merge the development branch
138+
git merge newfeature
139+
140+
# Push master with the new feature merged into it
141+
git push origin master
142+
```
143+
144+
Now that you're done with the development branch, you're free to delete it.
145+
146+
```shell
147+
git branch -d newfeature
148+
```
149+
150+
151+
152+
**Copyright**
153+
154+
Copyright 2017, Chase Pettit
155+
156+
MIT License, http://www.opensource.org/licenses/mit-license.php
157+
158+
**Additional Reading**
159+
* [Atlassian - Merging vs. Rebasing](https://www.atlassian.com/git/tutorials/merging-vs-rebasing)
160+
161+
**Sources**
162+
* [GitHub - Fork a Repo](https://help.github.com/articles/fork-a-repo)
163+
* [GitHub - Syncing a Fork](https://help.github.com/articles/syncing-a-fork)
164+
* [GitHub - Checking Out a Pull Request](https://help.github.com/articles/checking-out-pull-requests-locally)

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
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.
1313

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

1616
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.
1717

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

2626
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).
2727

28+
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.
29+
2830
## Built With
2931

3032
### Programming languages
@@ -41,7 +43,7 @@ mysql
4143

4244
## Repos and projects
4345

44-
Related to https://github.com/code4romania/civichq-client
46+
Related to https://github.com/code4romania/civichq-client
4547

4648
## Deployment
4749

@@ -63,6 +65,14 @@ pm2 logs
6365
pm2 list
6466
```
6567

68+
### Docs
69+
70+
API docs with Swagger will be available at: http://localhost:8080/explorer
71+
72+
### Testing
73+
74+
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.
75+
6676
## Feedback
6777

6878
* Request a new feature on GitHub.

api/add-app-api.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function AddAppApi(
88
appcreationdate,
99
applogo,
1010
apptags,
11+
apptechnologies,
1112
ngoname,
1213
ngophone,
1314
ngoemail,
@@ -17,7 +18,8 @@ function AddAppApi(
1718
ngotwitter,
1819
ngoinstagram,
1920
ngodescription,
20-
ngologo
21+
ngologo,
22+
isActive
2123
){
2224
this.appname = appname;
2325
this.categoryid = categoryid;
@@ -28,6 +30,7 @@ function AddAppApi(
2830
this.appcreationdate = appcreationdate;
2931
this.applogo = applogo;
3032
this.apptags = apptags;
33+
this.apptechnologies = apptechnologies;
3134
this.ngoname = ngoname;
3235
this.ngophone = ngophone;
3336
this.ngoemail = ngoemail;
@@ -38,14 +41,15 @@ function AddAppApi(
3841
this.ngoinstagram = ngoinstagram;
3942
this.ngodescription = ngodescription;
4043
this.ngologo = ngologo;
44+
this.isActive = isActive;
4145

4246
}
4347

4448
AddAppApi.prototype = {
4549

4650
AddApp: function(res, seq){
4751

48-
seq.query('CALL AddApp (:apname , :categoryid , :appwebsite , :appfacebook , :appgithub , :appdescription , :appcreationdate , :applogo , :apptags , :ngname , :ngophone , :ngoemail , :ngofacebook , :ngogoogleplus , :ngolinkedin , :ngotwitter , :ngoinstagram , :ngodescription , :ngologo );', {replacements: {
52+
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: {
4953
apname: this.appname,
5054
categoryid: this.categoryid,
5155
appwebsite: this.appwebsite || null,
@@ -55,6 +59,7 @@ AddAppApi.prototype = {
5559
appcreationdate: this.appcreationdate || null,
5660
applogo: this.applogo || null,
5761
apptags: this.apptags || null,
62+
apptechnologies: this.apptechnologies || null,
5863
ngname: this.ngoname,
5964
ngophone: this.ngophone || null,
6065
ngoemail: this.ngoemail,
@@ -64,7 +69,8 @@ AddAppApi.prototype = {
6469
ngotwitter: this.ngotwitter || null,
6570
ngoinstagram: this.ngoinstagram || null,
6671
ngodescription: this.ngodescription || null,
67-
ngologo: this.ngologo || null
72+
ngologo: this.ngologo || null,
73+
appisactive: this.isActive === true ? 1 : 0
6874
}}).then(function(r){
6975
res.send(r[0]);
7076
}).catch(function(err){
@@ -76,4 +82,4 @@ AddAppApi.prototype = {
7682
}
7783

7884

79-
module.exports = AddAppApi;
85+
module.exports = AddAppApi;

api/approve-api.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var BaseAppQuery = require('./base-app-query');
2+
var ResponseFormatter = require('./response-formatter');
23

34
function ApproveApi() {
45

@@ -31,7 +32,7 @@ ApproveApi.prototype = {
3132

3233
var p1 = seq.query(query,
3334
{
34-
replacements: {appId: appId },
35+
replacements: { appId: appId },
3536
type: seq.QueryTypes.UPDATE
3637
}
3738
)
@@ -45,6 +46,46 @@ ApproveApi.prototype = {
4546
});
4647
});
4748

49+
},
50+
51+
EditApp: function (res, seq, reqBody, logoSavePath, isDebug) {
52+
var resp = new ResponseFormatter(isDebug);
53+
console.log(JSON.stringify(reqBody, null, 4));
54+
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 );', {
55+
replacements: {
56+
appid: reqBody.appid,
57+
apname: reqBody.appname,
58+
categoryid: reqBody.appcategoryid,
59+
appwebsite: reqBody.appwebsite || null,
60+
appfacebook: reqBody.appfacebook || null,
61+
appgithub: reqBody.appgithub || null,
62+
appdescription: reqBody.appdescription || null,
63+
apptechnologies: reqBody.apptechnologies || null,
64+
appcreationdate: reqBody.appcreationdate || null,
65+
applogo: logoSavePath + reqBody.applogoname || null,
66+
apptags: reqBody.apphashtags || null,
67+
ngname: reqBody.ngoname,
68+
ngophone: reqBody.ngophone || null,
69+
ngoemail: reqBody.ngoemail,
70+
ngofacebook: reqBody.ngofacebook || null,
71+
ngogoogleplus: reqBody.ngogoogleplus || null,
72+
ngolinkedin: reqBody.ngolinkedin || null,
73+
ngotwitter: reqBody.ngotwitter || null,
74+
ngoinstagram: reqBody.ngoinstagram || null,
75+
ngodescription: reqBody.ngodescription || null,
76+
ngologo: logoSavePath + reqBody.ngologoname || null,
77+
ngoid: reqBody.ngoid,
78+
appisactive: reqBody.isActive === true ? 1 : 0
79+
}
80+
}).then(function (rez) {
81+
resp.FormatFromResult(res, rez[0].result);
82+
83+
})
84+
.catch(
85+
function (err) {
86+
res.send(resp.FormatError(err));
87+
}
88+
);
4889
}
4990

5091
}

api/base-app-query.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ function BaseAppQuery() {
1010
'c.Id as \'appdetail.categoryid\',' +
1111
'c.CatName as \'appdetail.categoryname\',' +
1212
'a.tags as \'appdetail.hashtags\',' +
13+
'a.technologies as \'appdetail.technologies\',' +
1314
'a.github as \'appdetail.github\',' +
1415
'case when a.IsApproved = 1 then \'true\' else \'false\' end AS \'appdetail.isapproved\',' +
16+
'case when a.IsActive = 1 then \'true\' else \'false\' end AS \'appdetail.isactive\',' +
17+
'n.Id as \'ngodetail.id\',' +
1518
'n.NgoName as \'ngodetail.name\',' +
1619
'n.phone as \'ngodetail.phone\',' +
1720
'n.email as \'ngodetail.email\',' +
@@ -36,4 +39,4 @@ BaseAppQuery.prototype = {
3639
}
3740
}
3841

39-
module.exports = BaseAppQuery;
42+
module.exports = BaseAppQuery;

0 commit comments

Comments
 (0)