diff --git a/.DS_Store b/.DS_Store index b10de2d5..18c379cf 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/osinaweb/billing/__pycache__/models.cpython-310.pyc b/osinaweb/billing/__pycache__/models.cpython-310.pyc index fcdb79f4..93eb97ee 100644 Binary files a/osinaweb/billing/__pycache__/models.cpython-310.pyc and b/osinaweb/billing/__pycache__/models.cpython-310.pyc differ diff --git a/osinaweb/billing/migrations/0037_recurringcycle_item.py b/osinaweb/billing/migrations/0037_recurringcycle_item.py new file mode 100644 index 00000000..51112cc4 --- /dev/null +++ b/osinaweb/billing/migrations/0037_recurringcycle_item.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.5 on 2024-04-18 13:26 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('billing', '0036_alter_invoice_invoice_number'), + ] + + operations = [ + migrations.AddField( + model_name='recurringcycle', + name='item', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='billing.item'), + ), + ] diff --git a/osinaweb/billing/migrations/__pycache__/0037_recurringcycle_item.cpython-310.pyc b/osinaweb/billing/migrations/__pycache__/0037_recurringcycle_item.cpython-310.pyc new file mode 100644 index 00000000..0729c5d2 Binary files /dev/null and b/osinaweb/billing/migrations/__pycache__/0037_recurringcycle_item.cpython-310.pyc differ diff --git a/osinaweb/billing/models.py b/osinaweb/billing/models.py index 7b08a4ee..591d21b0 100644 --- a/osinaweb/billing/models.py +++ b/osinaweb/billing/models.py @@ -4,14 +4,6 @@ import requests # Create your models here. - -class RecurringCycle(models.Model): - months = models.IntegerField() - def __str__(self): - return f"{self.months} months" - - - class Item(models.Model): TYPE = ( ('Product', 'Product'), @@ -28,6 +20,13 @@ class Item(models.Model): return self.title +class RecurringCycle(models.Model): + item = models.ForeignKey(Item, on_delete=models.CASCADE, null=True) + months = models.IntegerField() + def __str__(self): + return f"{self.months} months" + + class Order(models.Model): STATUS = ( ('Completed', 'Completed'), diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 57fa68d3..f5fe38cd 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc b/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc index f1a6a3e1..55f5b23d 100644 Binary files a/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc index 86c1802b..976619c8 100644 Binary files a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc b/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc index 518051bd..450b6dfc 100644 Binary files a/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc index 48693ec5..adf8b7b0 100644 Binary files a/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/add/urls.py b/osinaweb/osinacore/add/urls.py index 07fd2fac..7af80a63 100644 --- a/osinaweb/osinacore/add/urls.py +++ b/osinaweb/osinacore/add/urls.py @@ -8,13 +8,12 @@ urlpatterns = [ path('customer/', views.add_customer, name='addcustomer'), path('business/', views.add_business, name='addbusiness'), - path('businessmodal/', views.add_business_modal, name='addbusinessmodal'), path('staff/', views.add_staff, name='adduser'), path('project/', views.add_project, name='addproject'), path('userstory//', views.add_user_story_modal, name='adduserstorymodal'), - path('projectnote//', views.add_project_note_modal, name='addprojectnotemodal'), path('file/', views.add_file_modal, name='addfilemodal'), path('credential/', views.add_credential_modal, name='addcredentialmodal'), + path('projectnote//', views.add_note_modal, name='addprojectnotemodal'), path('task/', views.add_task, name='addtask'), path('task//', views.add_task, name='addprojecttask'), path('task///', views.add_task, name='adduserstorytask'), diff --git a/osinaweb/osinacore/add/views.py b/osinaweb/osinacore/add/views.py index e8e31fd0..554278de 100644 --- a/osinaweb/osinacore/add/views.py +++ b/osinaweb/osinacore/add/views.py @@ -129,52 +129,6 @@ def add_business(request): - - -@staff_login_required -def add_business_modal(request): - if request.method == 'POST': - name = request.POST.get('name') - email = request.POST.get('email') - financial_number = request.POST.get('financial_number') - phone_number = request.POST.get('phone_number') - vat = request.POST.get('vat') - if vat == 'true': - vat = True - else: - vat = False - commercial_registration = request.POST.get('commercial_registration') - website = request.POST.get('website') - logo = request.FILES.get('logo') - - business_type_id = request.POST.get('type') - business_type = get_object_or_404(BusinessType, id=business_type_id) - - business = Business( - name=name, - email=email, - financial_number=financial_number, - vat=vat, - commercial_registration=commercial_registration, - website=website, - type=business_type, - logo=logo, - phone_number=phone_number, - ) - business.save() - - - businesses = Business.objects.all() - - updated_options = [{'id': business.id, 'name': business.name} for business in businesses] - - - return JsonResponse(updated_options, safe=False) - - - return render(request, 'add_templates/addbusiness-modal.html') - - @staff_login_required def add_staff(request): staffpositions = StaffPosition.objects.all().order_by('-id') @@ -182,7 +136,7 @@ def add_staff(request): email = request.POST.get('email').lower() first_name = request.POST.get('first_name') last_name = request.POST.get('last_name') - username = f"{first_name.lower()}{last_name.lower()}" + username = f"{first_name.replace(' ', '').lower()}{last_name.replace(' ', '').lower()}" original_username = username counter = 1 @@ -190,10 +144,17 @@ def add_staff(request): username = f"{original_username.lower()}{counter}" counter += 1 + if request.POST.get('active'): + active = True + else: + active = False + user = User.objects.create_user( username=username, email=email, - password= request.POST.get('password2') + password= request.POST.get('password2'), + is_staff = True, + is_active = active ) user.first_name = first_name.lower().capitalize() user.last_name = last_name.lower().capitalize() @@ -202,12 +163,17 @@ def add_staff(request): staff_positionid = request.POST.get('staff_position') staff_position = get_object_or_404(StaffPosition, id=staff_positionid) + if request.POST.get('intern'): + intern = True + else: + intern = False + StaffProfile.objects.create( user=user, image = request.FILES.get('image'), mobile_number = request.POST.get('mobile_number'), - active = request.POST.get('active'), - intern = request.POST.get('intern'), + active = active, + intern = intern, staff_position = staff_position, ) return redirect('users') @@ -299,35 +265,7 @@ def add_user_story_modal(request, project_id): } return render(request, 'add_templates/add-userstory-modal.html', context) - - - -@staff_login_required -def add_project_note_modal(request, project_id): - project = get_object_or_404(Project, project_id=project_id) - if request.method == 'POST': - text = request.POST.get('note_text') - color = request.POST.get('note_color') - user = request.user - date = timezone.now() - - note = Note( - text=text, - color=color, - user=user, - date=date, - project=project, - ) - note.save() - - return HttpResponse('') - - context = { - 'project' : project - } - - return render(request, 'add_templates/add-project-note-modal.html', context) - + @staff_login_required @@ -492,7 +430,12 @@ def add_epic(request, project_id): @staff_login_required -def add_note_modal(request, *args, **kwargs): +def add_note_modal(request, project_id=None): + project = None + if project_id: #Case where user wants to add note for a project page(Adding a note for a project) + project = get_object_or_404(Project, project_id=project_id) + else: + project = None if request.method == 'POST': text = request.POST.get('note_text') color = request.POST.get('note_color') @@ -504,12 +447,16 @@ def add_note_modal(request, *args, **kwargs): color=color, user=user, date=date, + project=project, ) note.save() # Reload the parent page return HttpResponse('') - return render(request, 'add_templates/add-note-modal.html') + context={ + 'project': project, + } + return render(request, 'add_templates/add-note-modal.html', context) diff --git a/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc index 04bf6d24..a01ee7b6 100644 Binary files a/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/edit/views.py b/osinaweb/osinacore/edit/views.py index d6d9690f..e62aed19 100644 --- a/osinaweb/osinacore/edit/views.py +++ b/osinaweb/osinacore/edit/views.py @@ -13,10 +13,6 @@ def edit_customer(request, customer_id): #Utilities references = Reference.objects.all() - businesses = Business.objects.all - customer_status = customer.status - customer_reference = customer.reference - customer_business = customer.business if request.method == 'POST': @@ -24,6 +20,7 @@ def edit_customer(request, customer_id): customer.user.first_name = request.POST.get('first_name') customer.user.last_name = request.POST.get('last_name') customer.user.email = request.POST.get('email') + customer.user.username = request.POST.get('email') customer.user.save() customer.mobile_number = request.POST.get('mobile_number') customer.personal_website = request.POST.get('personal_website') @@ -32,14 +29,6 @@ def edit_customer(request, customer_id): customer_reference = request.POST.get('reference') reference = get_object_or_404(Reference, id=customer_reference) customer.reference = reference - - if customer.business: - new_business = request.POST.get('business') - business = get_object_or_404(Business, id=new_business) - customer.business = business - - - customer.save() @@ -50,10 +39,6 @@ def edit_customer(request, customer_id): 'customer' : customer, 'references' : references, - 'businesses' : businesses, - 'customer_status' : customer_status, - 'customer_reference' : customer_reference, - 'customer_business' : customer_business, } return render(request, 'edit_templates/edit-customer.html', context) @@ -65,24 +50,26 @@ def edit_customer(request, customer_id): def edit_business(request, business_id): business = get_object_or_404(Business, business_id=business_id) business_types = BusinessType.objects.all().order_by('name') - current_business_type = None - if business.type: - current_business_type = business.type - + customers = CustomerProfile.objects.all().order_by('-id') if request.method == 'POST': business.name= request.POST.get('name') business.financial_number = request.POST.get('financial_number') business.commercial_registration = request.POST.get('commercial_registration') - business.vat = request.POST.get('vat') + if request.POST.get('vat'): + business.vat = True + else: + business.vat = False business.phone_number = request.POST.get('phone_number') business.website = request.POST.get('website') - - business_type = request.POST.get('business_type') - type = get_object_or_404(BusinessType, id=business_type) - business.type = type + if request.POST.get('business_type'): + business_type = request.POST.get('business_type') + type = get_object_or_404(BusinessType, id=business_type) + business.type = type + else: + business.type = None new_logo = request.FILES.get('logo') if new_logo: @@ -97,7 +84,7 @@ def edit_business(request, business_id): context = { 'business' : business, 'business_types' : business_types, - 'current_business_type' : current_business_type, + 'customers' : customers, } return render(request, 'edit_templates/edit-business.html', context) @@ -115,23 +102,30 @@ def edit_staff(request, staff_id): staff.user.first_name= request.POST.get('first_name') staff.user.last_name = request.POST.get('last_name') staff.user.email = request.POST.get('email') + if request.POST.get('active'): + active = True + else: + active = False + staff.user.is_active = active staff.user.save() staff.mobile_number = request.POST.get('mobile_number') - staff.active = request.POST.get('active') - staff.intern = request.POST.get('intern') - new_position_id = request.POST.get('staff_position') new_position = get_object_or_404(StaffPosition, id=new_position_id) staff.staff_position = new_position + staff.active = active new_image = request.FILES.get('image') if new_image: staff.image = new_image - staff.active = request.POST.get('active') == 'on' - staff.intern = request.POST.get('intern') == 'on' + + if request.POST.get('intern'): + intern = True + else: + intern = False + staff.intern = intern staff.save() diff --git a/osinaweb/osinacore/templates/add_templates/add-business.html b/osinaweb/osinacore/templates/add_templates/add-business.html index ca9cf1fb..0dc03862 100644 --- a/osinaweb/osinacore/templates/add_templates/add-business.html +++ b/osinaweb/osinacore/templates/add_templates/add-business.html @@ -12,6 +12,21 @@ {% csrf_token %}
+
+ +
+
+ + Upload + Logo + +
+
+
+
- Upload - Logo - -
-
- - -
-
- - -
-
- +
+ +
+ + +
+ +
diff --git a/osinaweb/osinacore/templates/add_templates/add-note-modal.html b/osinaweb/osinacore/templates/add_templates/add-note-modal.html index 4c6a107c..2d1d9080 100644 --- a/osinaweb/osinacore/templates/add_templates/add-note-modal.html +++ b/osinaweb/osinacore/templates/add_templates/add-note-modal.html @@ -14,7 +14,7 @@ -
+ {% csrf_token %}

Add Note

diff --git a/osinaweb/osinacore/templates/add_templates/add-project-note-modal.html b/osinaweb/osinacore/templates/add_templates/add-project-note-modal.html deleted file mode 100644 index e231a50a..00000000 --- a/osinaweb/osinacore/templates/add_templates/add-project-note-modal.html +++ /dev/null @@ -1,116 +0,0 @@ -{% load static %} - - - - - - - - Osina - - - - - - - - - {% csrf_token %} -

Add Note

- -
- - - -
- -
-
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
-
- -
- -
- - - -
- -
-
- - - \ No newline at end of file diff --git a/osinaweb/osinacore/templates/add_templates/add-staff.html b/osinaweb/osinacore/templates/add_templates/add-staff.html index 7f6efd34..e3b1efa5 100644 --- a/osinaweb/osinacore/templates/add_templates/add-staff.html +++ b/osinaweb/osinacore/templates/add_templates/add-staff.html @@ -64,6 +64,7 @@ +

Active

- +

Intern

-
diff --git a/osinaweb/osinacore/templates/add_templates/add-task.html b/osinaweb/osinacore/templates/add_templates/add-task.html index b04e64f2..e6e158b9 100644 --- a/osinaweb/osinacore/templates/add_templates/add-task.html +++ b/osinaweb/osinacore/templates/add_templates/add-task.html @@ -18,6 +18,8 @@ {% else %} action="{% url 'addtask' %}" {% endif %}> + + {% csrf_token %}
diff --git a/osinaweb/osinacore/templates/details_templates/project-details.html b/osinaweb/osinacore/templates/details_templates/project-details.html index 7affaddb..9f92763c 100644 --- a/osinaweb/osinacore/templates/details_templates/project-details.html +++ b/osinaweb/osinacore/templates/details_templates/project-details.html @@ -409,7 +409,7 @@
diff --git a/osinaweb/osinacore/templates/edit_templates/edit-business.html b/osinaweb/osinacore/templates/edit_templates/edit-business.html index 725b1c64..d5fa44de 100644 --- a/osinaweb/osinacore/templates/edit_templates/edit-business.html +++ b/osinaweb/osinacore/templates/edit_templates/edit-business.html @@ -13,6 +13,7 @@
+
{% if business.logo %} @@ -44,7 +45,21 @@
- + + +
+ +
+ @@ -59,7 +74,7 @@
- + @@ -87,36 +102,25 @@
- +
- - - + +
- -
diff --git a/osinaweb/osinacore/templates/edit_templates/edit-customer.html b/osinaweb/osinacore/templates/edit_templates/edit-customer.html index 13bd6007..020f2683 100644 --- a/osinaweb/osinacore/templates/edit_templates/edit-customer.html +++ b/osinaweb/osinacore/templates/edit_templates/edit-customer.html @@ -56,9 +56,9 @@ class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-1" required> - - - + + +
@@ -68,41 +68,13 @@ class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-1" required> {% for reference in references %} - {% endfor %}
- {% if not customer_business %} -
- - -
- {% endif %} - - - {% if customer_business %} -
- - -
- {% endif %} -
diff --git a/osinaweb/osinacore/templates/edit_templates/edit-project-type.html b/osinaweb/osinacore/templates/edit_templates/edit-project-type.html index 009218d3..a3b9c4af 100644 --- a/osinaweb/osinacore/templates/edit_templates/edit-project-type.html +++ b/osinaweb/osinacore/templates/edit_templates/edit-project-type.html @@ -13,7 +13,7 @@
- +
diff --git a/osinaweb/osinacore/templates/edit_templates/edit-staff.html b/osinaweb/osinacore/templates/edit_templates/edit-staff.html index f11483fa..89554a77 100644 --- a/osinaweb/osinacore/templates/edit_templates/edit-staff.html +++ b/osinaweb/osinacore/templates/edit_templates/edit-staff.html @@ -77,29 +77,19 @@
- {% if staff.active %} -
- -

Active

-
- {% else %} +
- -

Active

+ +

Active

- {% endif %} + - {% if staff.intern %} -
- -

Intern

-
- {% else %} +
- -

Intern

+ +

Intern

- {% endif %} +