Commit 54c90414 authored by Miguel Luis D. Bandelaria's avatar Miguel Luis D. Bandelaria

resolved branching and cache issues

parents c34343fa 890d7211
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
\ No newline at end of file
from django.contrib import admin from django.contrib import admin
# Register your models here. # Register your models here.
from .models import WidgetUser from .models import WidgetUser, Department
admin.site.register(WidgetUser) admin.site.register(WidgetUser)
admin.site.register(Department)
# Generated by Django 4.0.3 on 2022-03-24 11:06
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0003_remove_widgetuser_department_department_department_and_more'),
]
operations = [
migrations.RenameField(
model_name='department',
old_name='department',
new_name='widgetuser',
),
]
# Generated by Django 4.0.3 on 2022-03-24 11:44
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0004_rename_department_department_widgetuser'),
]
operations = [
migrations.RemoveField(
model_name='department',
name='widgetuser',
),
migrations.AddField(
model_name='widgetuser',
name='department',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.department'),
),
]
# Generated by Django 4.0.3 on 2022-04-01 13:48
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0005_remove_department_widgetuser_widgetuser_department'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='department',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='department', to='homepage.department'),
),
]
from django.db import models from django.db import models
class Department(models.Model):
dept_name = models.CharField(max_length=50, null=True)
home_unit = models.CharField(max_length=50, null=True)
def __str__(self):
return self.dept_name
class WidgetUser(models.Model): class WidgetUser(models.Model):
first_name = models.CharField(max_length=50) first_name = models.CharField(max_length=50)
middle_name = models.CharField(max_length=50) middle_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50)
id_num = models.IntegerField(max_length=7, null=True) id_num = models.IntegerField(max_length=7, null=True)
email = models.EmailField(max_length=50, null=True) email = models.EmailField(max_length=50, null=True)
department = models.ForeignKey(Department,
on_delete=models.CASCADE,
null=True,
related_name='department')
def __str__(self):
# Create your models here. return self.first_name
class Department(models.Model): \ No newline at end of file
dept_name = models.CharField(max_length=50, null=True)
home_unit = models.CharField(max_length=50, null=True)
department = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, null=True)
from django.urls import path from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='index') path('', views.index, name='index'),
path('welcome', views.welcome, name='welcome')
] ]
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from .models import Department, WidgetUser
# Create your views here. # Create your views here.
def index(request): def welcome(request):
return HttpResponse('Welcome to Widget!') return HttpResponse('Welcome to Widget!')
def index(request):
widget_user_view = 'WIDGET USERS: '
widget_user = WidgetUser.objects.all()
for user in widget_user:
widget_user_view += "<br/> {}, {} {}: {}, {}, {}, {}".\
format(user.last_name,
user.first_name,
user.middle_name,
user.id_num,
user.email,
user.department.dept_name,
user.department.home_unit)
return HttpResponse(widget_user_view)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment