Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Unneccessary image #53

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django_pos/company/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@admin.register(Company)
class CompanyAdmin(admin.ModelAdmin):
list_display = ("company_name", "phone_number", "kra_pin", "city")
list_display = ("company_name", "phone_number", "kra_pin", "country")

def has_add_permission(self, request: HttpRequest) -> bool:
return Company.objects.all().count() < 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0.10 on 2024-12-23 16:02

import django_countries.fields
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('company', '0006_remove_branch_city_alter_branch_branch_id'),
]

operations = [
migrations.RemoveField(
model_name='company',
name='city',
),
migrations.AddField(
model_name='company',
name='country',
field=django_countries.fields.CountryField(blank=True, max_length=2, null=True),
),
]
7 changes: 4 additions & 3 deletions django_pos/company/models.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from django.db import models
from django_countries.fields import CountryField


class Company(models.Model):
phone_number = models.CharField(max_length=20, blank=True, null=True)
email = models.EmailField(blank=True, null=True)
city = models.CharField(max_length=100, blank=True, null=True)
address = models.CharField(max_length=100, blank=True, null=True)
logo = models.ImageField(blank=True, null=True, default="static/default.png")
company_name = models.CharField(max_length=100, blank=False, null=False)
currency_symbol = models.CharField(max_length=5, default="Kes")
kra_pin = models.CharField(max_length=11, blank=True, null=True)
# country
country = CountryField(blank=True, null=True)

def __str__(self) -> str:
return self.company_name
Expand All @@ -19,13 +21,12 @@ def to_dict(self) -> dict:
"id": self.id,
"phone": self.phone_number,
"email": self.email,
"city": self.city,
"address": self.address,
"company_name": self.company_name,
"currency": self.currency_symbol,
# if photo
"logo": self.logo.url or None,
"kra_pin": self.kra_pin,
"country": self.country,
}

class Meta:
Expand Down
8 changes: 7 additions & 1 deletion django_pos/company/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
from .serializers import CompanySerializer
from rest_framework.views import APIView
from rest_framework.response import Response
from django_countries import countries


@require_http_methods(["GET"])
def set_up_company(request):
return render(request, template_name="company/setup.html")
company = Company.objects.first()
context = {
"company": company,
"countries": countries,
}
return render(request, "company/setup.html", context)


class CompanyView(APIView):
Expand Down
21 changes: 21 additions & 0 deletions django_pos/django_pos/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,24 @@
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
DEFAULT_FROM_EMAIL = os.getenv("DEFAULT_FROM_EMAIL")

# LOGGING

LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"verbose": {
"format": "%(levelname)s %(asctime)s %(module)s "
"%(process)d %(thread)d %(message)s"
}
},
"handlers": {
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "verbose",
}
},
"root": {"level": "INFO", "handlers": ["console"]},
}
121 changes: 120 additions & 1 deletion django_pos/templates/company/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,129 @@
Company setup
{%endblock heading%}
{%block content%}
<div class="ml-2 mb-3">
<div class="mb-3">
<a class="btn btn-primary" href="{%url 'company:branches'%}">
<i class="ti ti-arrow-left"></i>
Back
</a>
</div>

<div class="card">
<div class="card-body">
<svg xmlns="http://www.w3.org/2000/svg" class="d-none">
<symbol id="check-circle-fill" viewBox="0 0 16 16">
<path
d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />
</symbol>
<symbol id="info-fill" viewBox="0 0 16 16">
<path
d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z" />
</symbol>
<symbol id="exclamation-triangle-fill" viewBox="0 0 16 16">
<path
d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z" />
</symbol>
</svg>

<div class="alert alert-info" role="alert">

<h4 class="alert-heading">
<svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="Info:">
<use xlink:href="#info-fill" />
</svg>
Company Setup
</h4>
<p>Setup your company details here</p>
<hr>
<p class="mb-0">
Please note that some functionalities may not work as expected if the company details are not set up
</p>
</div>
<section id="company">
<div class="ml-2 mb-3">
<form id="companyForm" method="post" enctype="multipart/form-data">
<div class="form-row">
<div class="form-group col-md-4">
{% if company.logo %}
<img src="{{company.logo}}" alt="Company Logo" id="logo"
style="width: 200px; height: 200px; object-fit: contain; border-radius: 10px;"
class="img-fluid">
{% else %}
<img src="{% static 'default.png' %}" alt="Company Logo"
style="box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);width: 200px; height: 200px; object-fit: contain; border-radius: 10px;"
class="img-fluid" id="logo">
{% endif %}
<button type="button" id="uploadImageBtn" class="btn btn-success mt-2">
Select Image
</button>
</div>
<div class="form-group col-md-8">
<div class="row">
<div class="col-md-6 mb-3">
<label for="companyName">Company Name</label>
<input type="text" class="form-control" id="companyName"
value="{{company.company_name}}">
</div>
<div class="col-md-6 mb-3">
<label for="address">Address</label>
<input type="text" class="form-control" id="address" value="{{company.address}}">
</div>
<div class="col-md-6 mb-3">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" value="{{company.email}}">
</div>
<div class="col-md-6 mb-3">
<label for="phone">Phone Number</label>
<input type="text" class="form-control" id="phone" value="{{company.phone_number}}">
</div>
<div class="col-md-6 mb-3">
<label for="currency">Currency</label>
<select class="form-control" id="currency">
<option value="KES" {% if company.currency == 'KES' %} selected {% endif %}>KES
</option>
<option value="USD" {% if company.currency == 'USD' %} selected {% endif %}>USD
</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label for="country">Country</label>
<select class="form-control" id="country" name="country">
{% for country in countries %}
<option value="{{ country.code }}" {% if company.country == country.code %}
selected {% endif %}>
{{ country.name }}
</option>
{% endfor %}
</select>
</div>
</div>
</div>
</div>
<p class="d-inline-flex gap-1">
<a data-bs-toggle="collapse" href="#collapseExample" role="button"
class="dropdown-toggle text-primary" aria-expanded="false" aria-controls="collapseExample">

Add more details
</a>
</p>
<div class="collapse" id="collapseExample">
<div class="form-group">
<label for="kra_pin">KRA PIN
<span class="text-muted" data-toggle="tooltip" data-placement="top"
title="Only applicable in Kenya">
<i class="ti ti-info-circle"></i>
</span>
</label>
<input type="text" class="form-control" id="kra_pin" value="{{company.kra_pin}}">
</div>
</div>
<button type="submit" class="btn btn-primary">

Save
</button>
</form>
</div>
</section>
</div>
</div>
{%endblock content%}
2 changes: 1 addition & 1 deletion django_pos/templates/pos/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@
<script src="{%static 'js/select2.min.js'%}" defer></script>
<script src="{% static 'assets/bootstrap-touchspin-master/src/jquery.bootstrap-touchspin.js' %}"></script>
<script src="{%static 'js/sweetalert2.all.min.js'%}"></script>
<script src="{%static 'js/popper.min.js'%}"></script>
<script src="{%static 'libs/bootstrap/dist/js/bootstrap.bundle.min.js'%}"></script>
<script src="{% static 'js/color-modes.js' %}"></script>
<script src="{%static 'libs/toastr/toastr.js'%}"></script>
<script src="{%static 'assets/bootstrap/js/popper.min.js'%}"></script>



Expand Down
Binary file removed image.png
Binary file not shown.
Loading