mirror of
https://github.com/kristoferssolo/FOSSDB.git
synced 2025-10-21 17:50:35 +00:00
Moved HostingPlatform to separate folder
This commit is contained in:
parent
e0f2e615f3
commit
0b0d6539dc
@ -1,8 +1,9 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .host.models import HostingPlatform, ProjectHostingPlatform
|
||||||
from .language.models import ProgrammingLanguage, ProjectProgrammingLanguage
|
from .language.models import ProgrammingLanguage, ProjectProgrammingLanguage
|
||||||
from .license.models import License
|
from .license.models import License
|
||||||
from .models import HostingPlatform, Project, ProjectHostingPlatform, Tag
|
from .models import Project, Tag
|
||||||
|
|
||||||
|
|
||||||
class ProjectProgrammingLanguageInline(admin.TabularInline):
|
class ProjectProgrammingLanguageInline(admin.TabularInline):
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from .models import HostingPlatform, Project, ProjectHostingPlatform
|
from .models import Project
|
||||||
|
|
||||||
|
|
||||||
class ProjectForm(forms.ModelForm):
|
class ProjectForm(forms.ModelForm):
|
||||||
@ -20,20 +20,3 @@ class ProjectForm(forms.ModelForm):
|
|||||||
}),
|
}),
|
||||||
"licenses": forms.CheckboxSelectMultiple(),
|
"licenses": forms.CheckboxSelectMultiple(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class HostingPlatformForm(forms.ModelForm):
|
|
||||||
url = forms.URLField()
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = HostingPlatform
|
|
||||||
fields = ["hosting_platform", "url"]
|
|
||||||
|
|
||||||
|
|
||||||
ProjectHostingPlatformFormSet = forms.inlineformset_factory(
|
|
||||||
Project,
|
|
||||||
ProjectHostingPlatform,
|
|
||||||
form=HostingPlatformForm,
|
|
||||||
extra=1,
|
|
||||||
can_delete=False
|
|
||||||
)
|
|
||||||
|
|||||||
22
FOSSDB_web/apps/fossdb/host/forms.py
Normal file
22
FOSSDB_web/apps/fossdb/host/forms.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from django import forms
|
||||||
|
|
||||||
|
from fossdb.models import Project
|
||||||
|
|
||||||
|
from .models import HostingPlatform, ProjectHostingPlatform
|
||||||
|
|
||||||
|
|
||||||
|
class HostingPlatformForm(forms.ModelForm):
|
||||||
|
url = forms.URLField()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = HostingPlatform
|
||||||
|
fields = ["hosting_platform", "url"]
|
||||||
|
|
||||||
|
|
||||||
|
ProjectHostingPlatformFormSet = forms.inlineformset_factory(
|
||||||
|
Project,
|
||||||
|
ProjectHostingPlatform,
|
||||||
|
form=HostingPlatformForm,
|
||||||
|
extra=1,
|
||||||
|
can_delete=False
|
||||||
|
)
|
||||||
17
FOSSDB_web/apps/fossdb/host/models.py
Normal file
17
FOSSDB_web/apps/fossdb/host/models.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class HostingPlatform(models.Model):
|
||||||
|
hosting_platform = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.hosting_platform
|
||||||
|
|
||||||
|
|
||||||
|
class ProjectHostingPlatform(models.Model):
|
||||||
|
project = models.ForeignKey("Project", on_delete=models.CASCADE)
|
||||||
|
hosting_platform = models.ForeignKey(HostingPlatform, on_delete=models.CASCADE)
|
||||||
|
url = models.URLField()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.project} | {self.hosting_platform}"
|
||||||
@ -3,19 +3,9 @@ import uuid
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from .language.models import ProgrammingLanguage
|
|
||||||
from .license.models import License
|
|
||||||
|
|
||||||
User = settings.AUTH_USER_MODEL
|
User = settings.AUTH_USER_MODEL
|
||||||
|
|
||||||
|
|
||||||
class HostingPlatform(models.Model):
|
|
||||||
hosting_platform = models.CharField(max_length=100)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.hosting_platform
|
|
||||||
|
|
||||||
|
|
||||||
class Tag(models.Model):
|
class Tag(models.Model):
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
description = models.TextField(blank=True, default="")
|
description = models.TextField(blank=True, default="")
|
||||||
@ -25,23 +15,14 @@ class Tag(models.Model):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class ProjectHostingPlatform(models.Model):
|
|
||||||
project = models.ForeignKey("Project", on_delete=models.CASCADE)
|
|
||||||
hosting_platform = models.ForeignKey(HostingPlatform, on_delete=models.CASCADE)
|
|
||||||
url = models.URLField()
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return f"{self.project} | {self.hosting_platform}"
|
|
||||||
|
|
||||||
|
|
||||||
class Project(models.Model):
|
class Project(models.Model):
|
||||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||||
author = models.ForeignKey(User, on_delete=models.CASCADE)
|
author = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
description = models.TextField(blank=True, default="")
|
description = models.TextField(blank=True, default="")
|
||||||
licenses = models.ManyToManyField(License)
|
licenses = models.ManyToManyField("License")
|
||||||
programming_languages = models.ManyToManyField(ProgrammingLanguage, through="ProjectProgrammingLanguage", related_name="projects")
|
programming_languages = models.ManyToManyField("ProgrammingLanguage", through="ProjectProgrammingLanguage", related_name="projects")
|
||||||
hosting_platform = models.ManyToManyField(HostingPlatform, through="ProjectHostingPlatform", related_name="projects")
|
hosting_platform = models.ManyToManyField("HostingPlatform", through="ProjectHostingPlatform", related_name="projects")
|
||||||
tag = models.ManyToManyField(Tag)
|
tag = models.ManyToManyField(Tag)
|
||||||
date_created = models.DateTimeField(auto_now_add=True)
|
date_created = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.shortcuts import redirect, render
|
from django.shortcuts import redirect, render
|
||||||
|
|
||||||
from .forms import ProjectForm, ProjectHostingPlatformFormSet
|
from .forms import ProjectForm
|
||||||
|
from .host.forms import ProjectHostingPlatformFormSet
|
||||||
from .language.forms import ProjectProgrammingLanguageFormSet
|
from .language.forms import ProjectProgrammingLanguageFormSet
|
||||||
from .models import Project
|
from .models import Project
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user