Skip to content

Commit 53964f8

Browse files
authored
Merge pull request #501 from hikaya-io/staging
Update master with code on staging
2 parents 4d932e6 + 38e5cbd commit 53964f8

File tree

3,261 files changed

+9416
-463669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,261 files changed

+9416
-463669
lines changed

.github/workflows/activity_ci_cd.yml

+50-22
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ on:
44
push:
55
branches:
66
- dev
7-
- master
7+
- staging
88
pull_request:
99
branches:
1010
- dev
11-
- master
11+
- staging
12+
release:
13+
types:
14+
- created
1215

1316
jobs:
1417
Build_and_test:
@@ -72,8 +75,19 @@ jobs:
7275
SERVICE_ACCESS_TOKEN: ${{ secrets.SERVICE_ACCESS_TOKEN }}
7376
DB_SIZE: ${{ secrets.DB_SIZE }}
7477
PG_VERSION: ${{ secrets.PG_VERSION }}
75-
DB_NAME_DEV_ENV: ${{ secrets.DB_NAME_DEV_ENV}}
76-
78+
DB_NAME_DEV_ENV: ${{ secrets.DB_NAME_DEV_ENV }}
79+
# staging vars, some are reused from dev_env
80+
BACKEND_BUCKET_STAGING: ${{ secrets.BACKEND_BUCKET_STAGING }}
81+
STATE_FILE_STAGING: ${{ secrets.STATE_FILE_STAGING }}
82+
CLUSTER_NAME_STAGING: ${{ secrets.CLUSTER_NAME_STAGING }}
83+
K8S_VERSION_STAGING: ${{ secrets.K8S_VERSION_STAGING }}
84+
DB_NAME_STAGING: ${{ secrets.DB_NAME_STAGING }}
85+
# Prod vars
86+
BACKEND_BUCKET_PROD: ${{ secrets.BACKEND_BUCKET_PROD }}
87+
STATE_FILE_PROD: ${{ secrets.STATE_FILE_PROD }}
88+
CLUSTER_NAME_PROD: ${{ secrets.CLUSTER_NAME_PROD }}
89+
K8S_VERSION_PROD: ${{ secrets.K8S_VERSION_PROD }}
90+
DB_NAME_PROD: ${{ secrets.DB_NAME_PROD }}
7791
run: |
7892
export TRAVIS_EVENT_TYPE="push"
7993
chmod +x ci-scripts/create_infrastructure.sh
@@ -100,27 +114,35 @@ jobs:
100114
ACTIVITY_CE_DB_USER_DEV: ${{ secrets.ACTIVITY_CE_DB_USER_DEV }}
101115
ACTIVITY_CE_DB_PASSWORD_DEV: ${{ secrets.ACTIVITY_CE_DB_PASSWORD_DEV }}
102116
ACTIVITY_CE_DB_HOST_DEV: ${{ secrets.ACTIVITY_CE_DB_HOST_DEV }}
103-
SECRET_KEY_DEV_ENV: ${{ secrets.SECRET_KEY_DEV_ENV }}
117+
SECRET_KEY: ${{ secrets.SECRET_KEY }}
104118
DEBUG: ${{ secrets.DEBUG }}
105119
DJANGO_ALLOWED_HOSTS: ${{ secrets.DJANGO_ALLOWED_HOSTS }}
106120
DB_ENGINE: ${{ secrets.DB_ENGINE }}
107121
ACTIVITY_CE_DB_PORT_DEV: ${{ secrets.ACTIVITY_CE_DB_PORT_DEV }}
108122
APPLICATION_ENV: ${{ secrets.APPLICATION_ENV }}
109123
EMAIL_PORT: ${{ secrets.EMAIL_PORT }}
110-
EMAIL_HOST_USER_DEV: ${{ secrets.EMAIL_HOST_USER_DEV }}
111-
EMAIL_HOST_PASSWORD_DEV: ${{ secrets.EMAIL_HOST_PASSWORD_DEV }}
124+
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }}
125+
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }}
112126
EMAIL_HOST: ${{ secrets.EMAIL_HOST }}
113-
GOOGLE_MAP_API_KEY_DEV: ${{ secrets.GOOGLE_MAP_API_KEY_DEV }}
127+
GOOGLE_MAP_API_KEY: ${{ secrets.GOOGLE_MAP_API_KEY }}
114128
APPLICATION_NAME: ${{ secrets.APPLICATION_NAME }}
115129
REGISTRY_OWNER: ${{ secrets.REGISTRY_OWNER }}
116-
130+
# staging variables. others are reused from dev
131+
ACTIVITY_CE_DB_NAME_STAGING: ${{ secrets.ACTIVITY_CE_DB_NAME_STAGING }}
132+
APPLICATION_ENV_STAGING: ${{ secrets.APPLICATION_ENV_STAGING }}
133+
# Production Vars
134+
APPLICATION_ENV_PROD: ${{ secrets.APPLICATION_ENV_PROD }}
135+
ACTIVITY_CE_DB_NAME_PROD: ${{ secrets.ACTIVITY_CE_DB_NAME_PROD }}
136+
ACTIVITY_CE_DB_USER_PROD: ${{ secrets.ACTIVITY_CE_DB_USER_PROD }}
137+
ACTIVITY_CE_DB_PASSWORD_PROD: ${{ secrets.ACTIVITY_CE_DB_PASSWORD_PROD }}
138+
ACTIVITY_CE_DB_HOST_PROD: ${{ secrets.ACTIVITY_CE_DB_HOST_PROD }}
139+
ACTIVITY_CE_DB_PORT_PROD: ${{ secrets.ACTIVITY_CE_DB_PORT_PROD }}
117140
run: |
118141
export TRAVIS_COMMIT=$GITHUB_SHA
119142
export TRAVIS_EVENT_TYPE="push"
120143
chmod +x ci-scripts/build_docker_image.sh
121144
bash ./ci-scripts/build_docker_image.sh
122145
123-
124146
Deploy:
125147
needs: Build_and_push_image
126148
runs-on: ubuntu-latest
@@ -141,21 +163,27 @@ jobs:
141163
HOST_DOMAIN: ${{ secrets.HOST_DOMAIN }}
142164
APPLICATION_NAME: ${{ secrets.APPLICATION_NAME }}
143165
REGISTRY_OWNER: ${{ secrets.REGISTRY_OWNER }}
166+
# staging variables
167+
CLUSTER_NAME_STAGING: ${{ secrets.CLUSTER_NAME_STAGING }}
168+
HOST_DOMAIN_STAGING: ${{ secrets.HOST_DOMAIN_STAGING }}
169+
APPLICATION_ENV_STAGING: ${{ secrets.APPLICATION_ENV_STAGING }}
170+
SLACK_CHANNEL_HOOK: ${{ secrets.SLACK_CHANNEL_HOOK }}
171+
# Production Vars
172+
APPLICATION_ENV_PROD: ${{ secrets.APPLICATION_ENV_PROD }}
173+
CLUSTER_NAME_PROD: ${{ secrets.CLUSTER_NAME_PROD }}
174+
HOST_DOMAIN_PROD: ${{ secrets.HOST_DOMAIN_PROD }}
144175
run: |
145176
export TRAVIS_COMMIT=$GITHUB_SHA
146177
export FILE_PATH="/github/home/.docker/config.json"
147178
export TRAVIS_EVENT_TYPE="push"
148179
chmod +x ci-scripts/deployment.sh
149180
bash ./ci-scripts/deployment.sh
150-
151-
Notify_slack:
152-
needs: Deploy
153-
runs-on: ubuntu-latest
154-
if: github.event.pull_request.merged
155-
steps:
156-
- uses: 8398a7/action-slack@v2
157-
with:
158-
status: ${{ job.status }}
159-
author_name: Github Actions Deploy
160-
env:
161-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CHANNEL_HOOK }}
181+
if [[ $? -eq 0 ]]; then
182+
export DEPLOY="success"
183+
else
184+
export DEPLOY="fail"
185+
fi
186+
export EMOJI=":github:"
187+
export TRAVIS_COMMIT_MESSAGE="No Commit message"
188+
chmod +x ci-scripts/notify_slack.sh
189+
bash ./ci-scripts/notify_slack.sh

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ language: minimal
55

66
notifications:
77
slack:
8-
if: branch = dev
8+
if: branch = dev OR branch = staging
99
on_pull_requests: false
1010
secure: OzJ+zoqdrsgO0Fx2cfat1EyfcqwkBi5WJ9zRr5cEZxb6Y3mlkiURuzE1jgLyvOwzJln0H+eWNlUZ6sy9ijpoEdKDJtAftkOkbQuk1WWG+kzbZ2zhMxKP32B0Cemy44VP3aHljPmzQQN58Pfl+IO1GbxGSaGN/DUPW8NXdKC7+I3RlGHoh0pVoqsnJgNKzf2G9uAfVMujs7Mhc9n6qoUNFp8kRHgphOAEP0+B5ioG6/lei2WKhEPzn582ElHODFSfyg/TSzH4lFHAudgZQ6roA5b4CQRfUUg1hLC4m9NBBTFBMXk1IACWt1rBp9ufgKRrRCVs1n1w9JSITXB5c6cmONQuv6IgjIuJuqd+bH9sqxl5Hd/FBemkNXS5jcQ+IgGiO8sMGgvZ+ZCb1rgQdUH6vUykOgHpiIgfDbOXQf5uE/o7yiSVKh/QncbRZ96pStV2HR5KOyYK7d27UBmtRnA9GtNK0EAw+GpQfu4/jn6gaBpSoArpbLpKt8NksYfDcpyo//xLCrxN0u8VdLdayCXcJ2OaFw9imd5NDB55GV4BfxG3JOQnUNA1pAdSZWPmvb8COTfHPeAxyU24qGgURU0xLppCkz3QybSjIjtR55bLAuoqhfKEBsaJhWoYQP6XEG8/eZm18swqZQG4QEVEOEWkPLnxwRPjk9KkJiPYphlCkdI=
1111
jobs:
@@ -37,7 +37,7 @@ jobs:
3737
- chmod +x ci-scripts/build_docker_image.sh
3838
- ./ci-scripts/build_docker_image.sh
3939

40-
# Stage to deploy application
40+
#@--- Stage to deploy application ---@#
4141
- stage: Deploy
4242
services:
4343
- docker

CONTRIBUTING.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Our current maintainers are: Peter Odeny ([@odenypeter](https://github.com/odeny
4949

5050
We have 3 main branches in our repo:
5151
- `Dev` - All bug fixes and enhancements
52-
- Feature branches (i.e. `ACT-001`) - All feature branches must be named like: ACT-001 (where ACT-001 is the issue number on Jira)
52+
- Feature branches (i.e. `ACT-001`) - All feature branches must be named like: ACT-001 (where ACT-001 is the issue number on GitHub)
5353
- `Staging` - This is our QA testing environment
5454
- `Master` - Clean code in production environment
5555

@@ -58,7 +58,7 @@ We have 3 main branches in our repo:
5858
- All pull requests should be based off of the `Dev` branch.
5959
- All branch names should follow the issue number such as: `ACT-001`. This should be the Github issue number.
6060

61-
**Commits (Smart Commits)**
61+
**Commits (Smart Commits, only for Jira)**
6262

6363
- For us to be able to track and link our issues on Github, we use smart commits (This is for issues tracked in Jira). Below is an example of smart commit:
6464
- ACT-001:- Update Activity UI based on styling guide
@@ -73,7 +73,7 @@ We have 3 main branches in our repo:
7373
- All set checks passes (We will set the checks for each individual project).
7474
- The bug/feature/enhancement in question is fully addressed
7575
- PRs must follow the predefined template. In the PR body, the following questions should be addressed (This is predefined when creating a new PR):
76-
- Descriptive Title
76+
- Descriptive Title: Add the issue number followed by a brief description of the ticket e.g., `ACT-001: Adds project status`
7777
- What is the purpose of the PR?
7878
- Approach used to address the issue
7979
- Any prerequisites before/after merging?
@@ -90,20 +90,21 @@ This repo is currently maintained by Hikaya, who have commit access. They will l
9090

9191
# Coding conventions
9292

93-
## Github labels
93+
## GitHub labels
9494
- ```Good first issue``` - Good for newcomers
9595
- ```bug``` - Something isn't working
9696
- ```defect``` - Something isn't working right
9797
- ```enhancement``` - New feature
98-
- ```dependencies``` - Updates dependecies
98+
- ```refactor``` - Refactoring existing code
99+
- ```dependencies``` - Updates dependencies
99100
- ```duplicate``` - Issue or pullrequest exists
100101
- ```help wanted``` - Extra attention is required
101102
- ```question``` - More information is needed
102-
- ```level 0``` - Insignificant task (minimal effort and time needed)
103-
- ```level 1``` - Simple issues requiring minimal effort
104-
- ```level 2``` - Not so complex, requiring a relatively goot amount of effort and time to fix
105-
- ```level 3``` - Complex task
106-
- ```level 4``` - Very complext task
103+
- ```1``` - Insignificant task (minimal effort and time needed)
104+
- ```2``` - Simple issues requiring minimal effort
105+
- ```3``` - Not so complex, requiring a relatively good amount of effort and time to fix
106+
- ```5``` - Complex task
107+
- ```8``` - Very complex task
107108

108109

109110
## Naming conventions
@@ -124,7 +125,7 @@ We'll continue updating this section as our product matures and more standards a
124125
- The project uses `Flake8` for python code linting.
125126

126127
## CI/CD
127-
- We are currently using Github Actions for simple build checks.
128+
- We are currently using GitHub Actions for simple build checks.
128129
- In the future, we will introduce more rigorous checks including unit tests, integration tests, end-to-end tests, and automatic deployments to `dev`.
129130

130131
# Community

activity/settings/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@
192192
'debug_toolbar.middleware.DebugToolbarMiddleware',
193193
'simple_history.middleware.HistoryRequestMiddleware',
194194
'social_django.middleware.SocialAuthExceptionMiddleware',
195-
'activity.middleware.TimingMiddleware'
195+
'activity.middleware.TimingMiddleware',
196196
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
197+
'whitenoise.middleware.WhiteNoiseMiddleware'
197198
)
198199
# END MIDDLEWARE CONFIGURATION
199200

activity/tokens.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TokenGenerator(PasswordResetTokenGenerator):
99
def _make_hash_value(self, user, timestamp):
1010
return (
1111
six.text_type(user.pk) + six.text_type(timestamp) +
12-
six.text_type(user.is_active)
12+
six.text_type(user.username)
1313
)
1414

1515

activity/views.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def admin_configurations(request):
493493
'form_label': data.get('form_label'),
494494
'stakeholder_label': data.get('stakeholder_label'),
495495
'date_format': data.get('date_format'),
496-
'beneficiary_label': data.get('beneficiary_label'),
496+
'individual_label': data.get('individual_label'),
497497
'training_label': data.get('training_label'),
498498
'distribution_label': data.get('distribution_label'),
499499
# 'default_currency': data.get('default_currency')
@@ -1141,14 +1141,26 @@ def invite_existing_user(request, invite_uuid):
11411141
user = User.objects.get(email=invite.email)
11421142
activity_user = ActivityUser.objects.filter(user=user).first()
11431143
if activity_user:
1144+
# Accepting the invite of an existing user
11441145
activity_user.organization = invite.organization
11451146
activity_user.save()
11461147
activity_user.organizations.add(invite.organization)
1147-
messages.error(request,
1148-
'You have successfully joined {}'.format(invite.organization.name))
1148+
11491149
# delete the invite
11501150
invite.delete()
1151+
# define user organization access groups
1152+
user_org_access = ActivityUserOrganizationGroup.objects.create(
1153+
activity_user=activity_user,
1154+
organization=invite.organization,
1155+
)
1156+
# set default permission to editor on invite
1157+
group = Group.objects.get(name='Editor')
1158+
user_org_access.group = group
1159+
user_org_access.save()
11511160

1161+
messages.success(request,
1162+
'You have successfully joined {}'.format(invite.organization.name))
1163+
# TODO this renders the login form even if the user is logged in
11521164
return render(request, 'registration/login.html', {'invite_uuid': invite_uuid})
11531165

11541166
# if user is not found
@@ -1162,7 +1174,7 @@ def invite_existing_user(request, invite_uuid):
11621174
return render(request, 'registration/login.html', {'invite_uuid': invite_uuid})
11631175

11641176
except UserInvite.DoesNotExist:
1165-
messages.error(request, 'Error, this invitation is no-longer valid')
1177+
messages.error(request, 'Error, this invitation is no longer valid')
11661178
return render(request, 'registration/login.html', {'invite_uuid': invite_uuid})
11671179

11681180

0 commit comments

Comments
 (0)