Skip to content

Commit

Permalink
new release
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin31 committed Sep 22, 2022
1 parent facb59c commit 42849fb
Show file tree
Hide file tree
Showing 109 changed files with 3,113 additions and 1,885 deletions.
24 changes: 24 additions & 0 deletions .runcode.yaml
@@ -0,0 +1,24 @@
onCreate:
- sudo apt-get update -y
- sudo apt install python-is-python3 xvfb libfontconfig wkhtmltopdf libpq-dev python3-dev python3-pip build-essential libssl-dev libffi-dev python3-venv redis-server redis-tools virtualenv zsh python3-virtualenv -y
- sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
- pip install virtualenvwrapper
- echo "source /home/ubuntu/.local/bin/virtualenvwrapper.sh" >> ~/.zshrc && source ~/.zshrc
- |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql
- |
sudo -u postgres psql postgres -c "ALTER USER postgres PASSWORD 'root'"
sudo -u postgres psql postgres -c "CREATE DATABASE bottlecrm WITH OWNER = postgres"
- |
mkvirtualenv bottlecrm
cp ENV.md .env
pip install -U pip
pip install -r requirements.txt
python manage.py migrate
onStart:
- |
workon bottlecrm
python manage.py runserver
51 changes: 35 additions & 16 deletions Dockerfile
@@ -1,21 +1,40 @@
FROM python:3.6
FROM ubuntu:20.04

WORKDIR /app
ARG APP_NAME

# Intall dependencies
COPY requirements.txt /app/
# test arg
RUN test -n "$APP_NAME"

RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt update && \
apt install -y git ruby-dev nodejs postgresql-client redis-server wkhtmltopdf && \
apt clean && \
gem install compass sass && \
npm -g install less && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir redis
# install system packages
RUN apt-get update -y
RUN apt-get install -y \
python3-pip \
python3-venv \
build-essential \
libpq-dev \
libmariadbclient-dev \
libjpeg62-dev \
zlib1g-dev \
libwebp-dev \
curl \
vim \
net-tools

COPY . /app/
# setup user
RUN useradd -ms /bin/bash ubuntu
USER ubuntu

RUN chmod +x /app/entrypoint.sh \
/app/wait-for-postgres.sh
ENTRYPOINT ["/app/entrypoint.sh"]
# install app
RUN mkdir -p /home/ubuntu/"$APP_NAME"/"$APP_NAME"
WORKDIR /home/ubuntu/"$APP_NAME"/"$APP_NAME"
COPY . .
RUN python3 -m venv ../venv
RUN . ../venv/bin/activate
RUN /home/ubuntu/"$APP_NAME"/venv/bin/pip install -U pip
RUN /home/ubuntu/"$APP_NAME"/venv/bin/pip install -r requirements.txt
RUN /home/ubuntu/"$APP_NAME"/venv/bin/pip install gunicorn

# setup path
ENV PATH="${PATH}:/home/ubuntu/$APP_NAME/$APP_NAME/scripts"

USER ubuntu
38 changes: 38 additions & 0 deletions ENV.md
@@ -0,0 +1,38 @@
# Environment variables

SECRET_KEY=""
ENV_TYPE="dev"
DOMAIN_NAME=""

# AWS
AWS_BUCKET_NAME=""

AWS_ACCESS_KEY_ID=""
AWS_SECRET_ACCESS_KEY=""
AWS_SES_REGION_NAME=""
AWS_SES_REGION_ENDPOINT=""


# DB
DBNAME="bottlecrm"
DBUSER="postgres"
DBPASSWORD="root"
DBHOST="localhost"
DBPORT=""

# Sentry
SENTRY_DSN=""

# Celery
CELERY_BROKER_URL=""
CELERY_RESULT_BACKEND=""

# Swagger
SWAGGER_ROOT_URL=""

#CACHES
MEMCACHELOCATION=""

# Email
DEFAULT_FROM_EMAIL=""
ADMIN_EMAIL=""
62 changes: 62 additions & 0 deletions Jenkinsfile
@@ -0,0 +1,62 @@
pipeline {
agent any

environment {
ENV_TYPE = "dev"
APP_NAME = "bottlecrm-api"
DOCKERHUB = credentials("dockerhub")
DOCKER_IMAGE_TAG = "build-${env.BUILD_NUMBER}-${env.GIT_COMMIT[0..7]}"
DOCKER_IMAGE = "ashwin31/bottlecrm-api:${env.DOCKER_IMAGE_TAG}"
DOCKER_CONFIG = "config.json"
}

stages {
stage("build") {
steps {
sh "pwd; whoami; ls -al;"
sh "docker build --build-arg APP_NAME=$APP_NAME -t ${env.DOCKER_IMAGE} ."
}
}

stage("push") {
steps {
sh "echo '$DOCKERHUB_PSW' | docker login -u $DOCKERHUB_USR --password-stdin"
sh "docker push ${env.DOCKER_IMAGE}"
}
}
stage('trigger deploy') {
steps {
build job: 'bottlecrm-api-deploy', parameters: [
string(
name: 'ENV_TYPE',
value: "${env.ENV_TYPE}"
),
string(
name: 'APP_NAME',
value: "${env.APP_NAME}"
),
string(
name: 'DOCKER_IMAGE',
value: "${env.DOCKER_IMAGE}"
)
]
}
}
}

post {
always {
cleanWs()
dir("${env.WORKSPACE}@tmp") {
deleteDir()
}
dir("${env.WORKSPACE}@script") {
deleteDir()
}
dir("${env.WORKSPACE}@script@tmp") {
deleteDir()
}
sh 'docker rmi $(docker images -aq) || true'
}
}
}
14 changes: 9 additions & 5 deletions README.md
@@ -1,5 +1,6 @@
# Django-CRM

============

Django CRM is opensource CRM developed on django framework. It has all
the basic features of CRM to start with. We welcome code contributions
Expand Down Expand Up @@ -32,7 +33,7 @@ We recommend ubuntu 20.04. These instructions are verified for ubuntu 20.04.
```
sudo apt update && sudo apt upgrade -y
sudo apt install python-is-python3 xvfb libfontconfig wkhtmltopdf git libpq-dev python3-dev python3-pip build-essential libssl-dev libffi-dev python3-venv redis-server redis-tools virtualenv -y
sudo apt install python-is-python3 xvfb libfontconfig wkhtmltopdf python3-dev python3-pip build-essential libssl-dev libffi-dev python3-venv redis-server redis-tools virtualenv -y
```

#### Install dependencies
Expand All @@ -45,11 +46,8 @@ sudo apt update && sudo apt upgrade -y && sudo apt install zsh python3-virtualen
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
pip install virtualenvwrapper
```
then add the following to ```~/.zshrc``` file
```
source /home/ubuntu/.local/bin/virtualenvwrapper.sh
echo "source /home/ubuntu/.local/bin/virtualenvwrapper.sh" >> ~/.zshrc
```

If you want to install postgres, follow https://www.postgresql.org/download/
Expand Down Expand Up @@ -89,7 +87,9 @@ python manage.py runserver
```
Then open http://localhost:8000/swagger/ in your borwser to explore API.

## start celery worker in another terminal window

celery -A tasks worker --loglevel=INFO

### Useful tools and packages

Expand Down Expand Up @@ -123,3 +123,7 @@ We welcome your feedback and support, raise github issue if you want to
report a bug or request new feature. we are glad to help.

For commercial support [Contact us](https://micropyramid.com/contact-us/)

# trigger deploy


34 changes: 23 additions & 11 deletions accounts/migrations/0013_auto_20210913_1918.py
Expand Up @@ -7,24 +7,36 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0034_auto_20210913_1918'),
('accounts', '0012_remove_account_company'),
("common", "0034_auto_20210913_1918"),
("accounts", "0012_remove_account_company"),
]

operations = [
migrations.AddField(
model_name='account',
name='company',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='common.company'),
model_name="account",
name="company",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="common.company",
),
),
migrations.AlterField(
model_name='account',
name='assigned_to',
field=models.ManyToManyField(related_name='account_assigned_users', to='common.Profile'),
model_name="account",
name="assigned_to",
field=models.ManyToManyField(
related_name="account_assigned_users", to="common.Profile"
),
),
migrations.AlterField(
model_name='account',
name='created_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='account_created_by', to='common.profile'),
model_name="account",
name="created_by",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="account_created_by",
to="common.profile",
),
),
]
8 changes: 4 additions & 4 deletions accounts/migrations/0014_rename_company_account_org.py
Expand Up @@ -6,13 +6,13 @@
class Migration(migrations.Migration):

dependencies = [
('accounts', '0013_auto_20210913_1918'),
("accounts", "0013_auto_20210913_1918"),
]

operations = [
migrations.RenameField(
model_name='account',
old_name='company',
new_name='org',
model_name="account",
old_name="company",
new_name="org",
),
]
16 changes: 11 additions & 5 deletions accounts/migrations/0015_alter_account_org.py
Expand Up @@ -7,14 +7,20 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0037_alter_profile_org'),
('accounts', '0014_rename_company_account_org'),
("common", "0037_alter_profile_org"),
("accounts", "0014_rename_company_account_org"),
]

operations = [
migrations.AlterField(
model_name='account',
name='org',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='account_org', to='common.org'),
model_name="account",
name="org",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="account_org",
to="common.org",
),
),
]
25 changes: 12 additions & 13 deletions accounts/models.py
@@ -1,7 +1,7 @@
import arrow
from django.db import models
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from common.models import Org, Profile
from common.utils import INDCHOICES, COUNTRIES
Expand All @@ -25,8 +25,7 @@ class Account(models.Model):

ACCOUNT_STATUS_CHOICE = (("open", "Open"), ("close", "Close"))

name = models.CharField(pgettext_lazy(
"Name of Account", "Name"), max_length=64)
name = models.CharField(pgettext_lazy("Name of Account", "Name"), max_length=64)
email = models.EmailField()
phone = PhoneNumberField(null=True)
industry = models.CharField(
Expand All @@ -39,12 +38,9 @@ class Account(models.Model):
billing_address_line = models.CharField(
_("Address"), max_length=255, blank=True, null=True
)
billing_street = models.CharField(
_("Street"), max_length=55, blank=True, null=True)
billing_city = models.CharField(
_("City"), max_length=255, blank=True, null=True)
billing_state = models.CharField(
_("State"), max_length=255, blank=True, null=True)
billing_street = models.CharField(_("Street"), max_length=55, blank=True, null=True)
billing_city = models.CharField(_("City"), max_length=255, blank=True, null=True)
billing_state = models.CharField(_("State"), max_length=255, blank=True, null=True)
billing_postcode = models.CharField(
_("Post/Zip-code"), max_length=64, blank=True, null=True
)
Expand All @@ -71,11 +67,14 @@ class Account(models.Model):
contacts = models.ManyToManyField(
"contacts.Contact", related_name="account_contacts"
)
assigned_to = models.ManyToManyField(
Profile, related_name="account_assigned_users")
assigned_to = models.ManyToManyField(Profile, related_name="account_assigned_users")
teams = models.ManyToManyField(Teams, related_name="account_teams")
org = models.ForeignKey(
Org, on_delete=models.SET_NULL, null=True, blank=True, related_name="account_org"
Org,
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="account_org",
)

class Meta:
Expand Down Expand Up @@ -146,7 +145,7 @@ def __str__(self):


class EmailLog(models.Model):
""" this model is used to track if the email is sent or not """
"""this model is used to track if the email is sent or not"""

email = models.ForeignKey(
Email, related_name="email_log", on_delete=models.SET_NULL, null=True
Expand Down

0 comments on commit 42849fb

Please sign in to comment.