Skip to content

Commit

Permalink
Merge pull request #501 from hikaya-io/staging
Browse files Browse the repository at this point in the history
Update master with code on staging
  • Loading branch information
odenypeter authored Apr 28, 2020
2 parents 4d932e6 + 38e5cbd commit 53964f8
Show file tree
Hide file tree
Showing 3,261 changed files with 9,416 additions and 463,669 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
72 changes: 50 additions & 22 deletions .github/workflows/activity_ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ on:
push:
branches:
- dev
- master
- staging
pull_request:
branches:
- dev
- master
- staging
release:
types:
- created

jobs:
Build_and_test:
Expand Down Expand Up @@ -72,8 +75,19 @@ jobs:
SERVICE_ACCESS_TOKEN: ${{ secrets.SERVICE_ACCESS_TOKEN }}
DB_SIZE: ${{ secrets.DB_SIZE }}
PG_VERSION: ${{ secrets.PG_VERSION }}
DB_NAME_DEV_ENV: ${{ secrets.DB_NAME_DEV_ENV}}

DB_NAME_DEV_ENV: ${{ secrets.DB_NAME_DEV_ENV }}
# staging vars, some are reused from dev_env
BACKEND_BUCKET_STAGING: ${{ secrets.BACKEND_BUCKET_STAGING }}
STATE_FILE_STAGING: ${{ secrets.STATE_FILE_STAGING }}
CLUSTER_NAME_STAGING: ${{ secrets.CLUSTER_NAME_STAGING }}
K8S_VERSION_STAGING: ${{ secrets.K8S_VERSION_STAGING }}
DB_NAME_STAGING: ${{ secrets.DB_NAME_STAGING }}
# Prod vars
BACKEND_BUCKET_PROD: ${{ secrets.BACKEND_BUCKET_PROD }}
STATE_FILE_PROD: ${{ secrets.STATE_FILE_PROD }}
CLUSTER_NAME_PROD: ${{ secrets.CLUSTER_NAME_PROD }}
K8S_VERSION_PROD: ${{ secrets.K8S_VERSION_PROD }}
DB_NAME_PROD: ${{ secrets.DB_NAME_PROD }}
run: |
export TRAVIS_EVENT_TYPE="push"
chmod +x ci-scripts/create_infrastructure.sh
Expand All @@ -100,27 +114,35 @@ jobs:
ACTIVITY_CE_DB_USER_DEV: ${{ secrets.ACTIVITY_CE_DB_USER_DEV }}
ACTIVITY_CE_DB_PASSWORD_DEV: ${{ secrets.ACTIVITY_CE_DB_PASSWORD_DEV }}
ACTIVITY_CE_DB_HOST_DEV: ${{ secrets.ACTIVITY_CE_DB_HOST_DEV }}
SECRET_KEY_DEV_ENV: ${{ secrets.SECRET_KEY_DEV_ENV }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
DEBUG: ${{ secrets.DEBUG }}
DJANGO_ALLOWED_HOSTS: ${{ secrets.DJANGO_ALLOWED_HOSTS }}
DB_ENGINE: ${{ secrets.DB_ENGINE }}
ACTIVITY_CE_DB_PORT_DEV: ${{ secrets.ACTIVITY_CE_DB_PORT_DEV }}
APPLICATION_ENV: ${{ secrets.APPLICATION_ENV }}
EMAIL_PORT: ${{ secrets.EMAIL_PORT }}
EMAIL_HOST_USER_DEV: ${{ secrets.EMAIL_HOST_USER_DEV }}
EMAIL_HOST_PASSWORD_DEV: ${{ secrets.EMAIL_HOST_PASSWORD_DEV }}
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }}
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }}
EMAIL_HOST: ${{ secrets.EMAIL_HOST }}
GOOGLE_MAP_API_KEY_DEV: ${{ secrets.GOOGLE_MAP_API_KEY_DEV }}
GOOGLE_MAP_API_KEY: ${{ secrets.GOOGLE_MAP_API_KEY }}
APPLICATION_NAME: ${{ secrets.APPLICATION_NAME }}
REGISTRY_OWNER: ${{ secrets.REGISTRY_OWNER }}

# staging variables. others are reused from dev
ACTIVITY_CE_DB_NAME_STAGING: ${{ secrets.ACTIVITY_CE_DB_NAME_STAGING }}
APPLICATION_ENV_STAGING: ${{ secrets.APPLICATION_ENV_STAGING }}
# Production Vars
APPLICATION_ENV_PROD: ${{ secrets.APPLICATION_ENV_PROD }}
ACTIVITY_CE_DB_NAME_PROD: ${{ secrets.ACTIVITY_CE_DB_NAME_PROD }}
ACTIVITY_CE_DB_USER_PROD: ${{ secrets.ACTIVITY_CE_DB_USER_PROD }}
ACTIVITY_CE_DB_PASSWORD_PROD: ${{ secrets.ACTIVITY_CE_DB_PASSWORD_PROD }}
ACTIVITY_CE_DB_HOST_PROD: ${{ secrets.ACTIVITY_CE_DB_HOST_PROD }}
ACTIVITY_CE_DB_PORT_PROD: ${{ secrets.ACTIVITY_CE_DB_PORT_PROD }}
run: |
export TRAVIS_COMMIT=$GITHUB_SHA
export TRAVIS_EVENT_TYPE="push"
chmod +x ci-scripts/build_docker_image.sh
bash ./ci-scripts/build_docker_image.sh
Deploy:
needs: Build_and_push_image
runs-on: ubuntu-latest
Expand All @@ -141,21 +163,27 @@ jobs:
HOST_DOMAIN: ${{ secrets.HOST_DOMAIN }}
APPLICATION_NAME: ${{ secrets.APPLICATION_NAME }}
REGISTRY_OWNER: ${{ secrets.REGISTRY_OWNER }}
# staging variables
CLUSTER_NAME_STAGING: ${{ secrets.CLUSTER_NAME_STAGING }}
HOST_DOMAIN_STAGING: ${{ secrets.HOST_DOMAIN_STAGING }}
APPLICATION_ENV_STAGING: ${{ secrets.APPLICATION_ENV_STAGING }}
SLACK_CHANNEL_HOOK: ${{ secrets.SLACK_CHANNEL_HOOK }}
# Production Vars
APPLICATION_ENV_PROD: ${{ secrets.APPLICATION_ENV_PROD }}
CLUSTER_NAME_PROD: ${{ secrets.CLUSTER_NAME_PROD }}
HOST_DOMAIN_PROD: ${{ secrets.HOST_DOMAIN_PROD }}
run: |
export TRAVIS_COMMIT=$GITHUB_SHA
export FILE_PATH="/github/home/.docker/config.json"
export TRAVIS_EVENT_TYPE="push"
chmod +x ci-scripts/deployment.sh
bash ./ci-scripts/deployment.sh
Notify_slack:
needs: Deploy
runs-on: ubuntu-latest
if: github.event.pull_request.merged
steps:
- uses: 8398a7/action-slack@v2
with:
status: ${{ job.status }}
author_name: Github Actions Deploy
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CHANNEL_HOOK }}
if [[ $? -eq 0 ]]; then
export DEPLOY="success"
else
export DEPLOY="fail"
fi
export EMOJI=":github:"
export TRAVIS_COMMIT_MESSAGE="No Commit message"
chmod +x ci-scripts/notify_slack.sh
bash ./ci-scripts/notify_slack.sh
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ language: minimal

notifications:
slack:
if: branch = dev
if: branch = dev OR branch = staging
on_pull_requests: false
secure: OzJ+zoqdrsgO0Fx2cfat1EyfcqwkBi5WJ9zRr5cEZxb6Y3mlkiURuzE1jgLyvOwzJln0H+eWNlUZ6sy9ijpoEdKDJtAftkOkbQuk1WWG+kzbZ2zhMxKP32B0Cemy44VP3aHljPmzQQN58Pfl+IO1GbxGSaGN/DUPW8NXdKC7+I3RlGHoh0pVoqsnJgNKzf2G9uAfVMujs7Mhc9n6qoUNFp8kRHgphOAEP0+B5ioG6/lei2WKhEPzn582ElHODFSfyg/TSzH4lFHAudgZQ6roA5b4CQRfUUg1hLC4m9NBBTFBMXk1IACWt1rBp9ufgKRrRCVs1n1w9JSITXB5c6cmONQuv6IgjIuJuqd+bH9sqxl5Hd/FBemkNXS5jcQ+IgGiO8sMGgvZ+ZCb1rgQdUH6vUykOgHpiIgfDbOXQf5uE/o7yiSVKh/QncbRZ96pStV2HR5KOyYK7d27UBmtRnA9GtNK0EAw+GpQfu4/jn6gaBpSoArpbLpKt8NksYfDcpyo//xLCrxN0u8VdLdayCXcJ2OaFw9imd5NDB55GV4BfxG3JOQnUNA1pAdSZWPmvb8COTfHPeAxyU24qGgURU0xLppCkz3QybSjIjtR55bLAuoqhfKEBsaJhWoYQP6XEG8/eZm18swqZQG4QEVEOEWkPLnxwRPjk9KkJiPYphlCkdI=
jobs:
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
- chmod +x ci-scripts/build_docker_image.sh
- ./ci-scripts/build_docker_image.sh

# Stage to deploy application
#@--- Stage to deploy application ---@#
- stage: Deploy
services:
- docker
Expand Down
23 changes: 12 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Our current maintainers are: Peter Odeny ([@odenypeter](https://github.com/odeny

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

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

**Commits (Smart Commits)**
**Commits (Smart Commits, only for Jira)**

- 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:
- ACT-001:- Update Activity UI based on styling guide
Expand All @@ -73,7 +73,7 @@ We have 3 main branches in our repo:
- All set checks passes (We will set the checks for each individual project).
- The bug/feature/enhancement in question is fully addressed
- PRs must follow the predefined template. In the PR body, the following questions should be addressed (This is predefined when creating a new PR):
- Descriptive Title
- Descriptive Title: Add the issue number followed by a brief description of the ticket e.g., `ACT-001: Adds project status`
- What is the purpose of the PR?
- Approach used to address the issue
- Any prerequisites before/after merging?
Expand All @@ -90,20 +90,21 @@ This repo is currently maintained by Hikaya, who have commit access. They will l

# Coding conventions

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


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

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

# Community
Expand Down
3 changes: 2 additions & 1 deletion activity/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@
'debug_toolbar.middleware.DebugToolbarMiddleware',
'simple_history.middleware.HistoryRequestMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
'activity.middleware.TimingMiddleware'
'activity.middleware.TimingMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware'
)
# END MIDDLEWARE CONFIGURATION

Expand Down
2 changes: 1 addition & 1 deletion activity/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TokenGenerator(PasswordResetTokenGenerator):
def _make_hash_value(self, user, timestamp):
return (
six.text_type(user.pk) + six.text_type(timestamp) +
six.text_type(user.is_active)
six.text_type(user.username)
)


Expand Down
20 changes: 16 additions & 4 deletions activity/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def admin_configurations(request):
'form_label': data.get('form_label'),
'stakeholder_label': data.get('stakeholder_label'),
'date_format': data.get('date_format'),
'beneficiary_label': data.get('beneficiary_label'),
'individual_label': data.get('individual_label'),
'training_label': data.get('training_label'),
'distribution_label': data.get('distribution_label'),
# 'default_currency': data.get('default_currency')
Expand Down Expand Up @@ -1141,14 +1141,26 @@ def invite_existing_user(request, invite_uuid):
user = User.objects.get(email=invite.email)
activity_user = ActivityUser.objects.filter(user=user).first()
if activity_user:
# Accepting the invite of an existing user
activity_user.organization = invite.organization
activity_user.save()
activity_user.organizations.add(invite.organization)
messages.error(request,
'You have successfully joined {}'.format(invite.organization.name))

# delete the invite
invite.delete()
# define user organization access groups
user_org_access = ActivityUserOrganizationGroup.objects.create(
activity_user=activity_user,
organization=invite.organization,
)
# set default permission to editor on invite
group = Group.objects.get(name='Editor')
user_org_access.group = group
user_org_access.save()

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

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

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


Expand Down
Loading

0 comments on commit 53964f8

Please sign in to comment.