Skip to content

Commit

Permalink
removed submodule, added website to project
Browse files Browse the repository at this point in the history
  • Loading branch information
leoBitto committed Dec 2, 2023
1 parent 98ad51f commit 6657653
Show file tree
Hide file tree
Showing 41 changed files with 1,309 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/website
Submodule website deleted from 09982f
138 changes: 138 additions & 0 deletions src/website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Django #
*.log
*.pot
*.pyc
__pycache__
db.sqlite3
media

# Backup files #
*.bak

# If you are using PyCharm #
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# File-based project format
*.iws

# IntelliJ
out/

# JIRA plugin
atlassian-ide-plugin.xml

# Python #
*.py[cod]
*$py.class

# Distribution / packaging
.Python build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery
celerybeat-schedule.*

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
env_dj/
venv/
ENV/
env.bak/
venv.bak/

# mkdocs documentation
/site

# mypy
.mypy_cache/

# Sublime Text #
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project

# sftp configuration file
sftp-config.json

# Package control specific files Package
Control.last-run
Control.ca-list
Control.ca-bundle
Control.system-ca-bundle
GitHub.sublime-settings

# Visual Studio Code #
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history
Empty file added src/website/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions src/website/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.contrib import admin
from .models import Image,Contact,Opening_hour, Gallery


class ImageAdmin(admin.ModelAdmin):
list_display=('id', 'gallery', 'description', 'is_first', 'show_image')


class GalleryAdmin(admin.ModelAdmin):
list_display=('id', 'name', 'get_images')


class ContactAdmin(admin.ModelAdmin):
list_display = ('id', 'phone', 'mail')


class OpeningHoursAdmin(admin.ModelAdmin):
list_display = ('id', 'weekdays', 'weekend', 'closing_day')


admin.site.register(Gallery, GalleryAdmin)
admin.site.register(Image, ImageAdmin)
admin.site.register(Contact, ContactAdmin)
admin.site.register(Opening_hour, OpeningHoursAdmin)
6 changes: 6 additions & 0 deletions src/website/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class WebsiteConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'website'
64 changes: 64 additions & 0 deletions src/website/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

# Website

The **website** app is a Django application designed to manage basic web pages within a website.

## Quick Start

1. Add "website" to your `INSTALLED_APPS` in your Django project's settings:

```python
INSTALLED_APPS = [
...
'website',
]

```



2. Include the website URLconf in your project urls.py like this::
you may want to add some url path inside the ''

> path('', include(('website.urls', 'website'), namespace="website")),

3. Run ``python manage.py migrate website`` to create the website models.

4. Start the development server and visit http://127.0.0.1:8000/admin/
to create the models (you'll need the Admin app enabled).

5. Visit http://127.0.0.1:8000 to see the website


-----------

# website docs
if you want to use the article links outside the app you need to use the namespace.
it is always a good idea when having many apps inside a Django project to use the namespace.
for example:

> <a href="{% url 'website:URL' %}"</a>


...

## User Registration

To enable user registration and authentication, follow these steps:

1. Add `'django.contrib.auth'` and `'django.contrib.auth.urls'` to your `INSTALLED_APPS` in your Django project's settings:

```python
INSTALLED_APPS = [
...
'django.contrib.auth',
...
]

2. Include the authentication URLconf in your **project**'s urls.py:


>path('accounts/', include('django.contrib.auth.urls')),


Now, your website should have user registration and authentication functionality. For more advanced features, refer to the Django Authentication documentation.
60 changes: 60 additions & 0 deletions src/website/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from django import forms
from .models import Image, Contact, Opening_hour, Gallery

class ImageForm(forms.ModelForm):
class Meta:
model = Image
fields = ['gallery', 'description', 'img', 'is_first']
widgets = {
'description': forms.TextInput(attrs={'placeholder': 'Necessaria ad identificarla'}),
}


class ContactForm(forms.ModelForm):
class Meta:
model = Contact
fields = ['phone', 'mail']
widgets = {
'phone': forms.TextInput(attrs={'placeholder': 'Inserisci il numero di telefono'}),
'mail': forms.TextInput(attrs={'placeholder': 'Inserisci l\'indirizzo email'}),
}


class OpeningHourForm(forms.ModelForm):
class Meta:
model = Opening_hour
fields = ['weekdays', 'weekend', 'closing_day']
widgets = {
'weekdays': forms.TextInput(attrs={'placeholder': 'Inserisci gli orari settimanali'}),
'weekend': forms.TextInput(attrs={'placeholder': 'Inserisci gli orari del weekend'}),
'closing_day': forms.TextInput(attrs={'placeholder': 'Inserisci un giorno della settimana'}),
}


class GalleryForm(forms.ModelForm):
class Meta:
model = Gallery
fields = ['name', 'images']
widgets = {
'name': forms.TextInput(attrs={'placeholder': 'Non usare spazi nel nome'}),
'images': forms.SelectMultiple(attrs={'class': 'form-control'}),
}

images = forms.ModelMultipleChoiceField(
queryset=Image.objects.filter(gallery__isnull=True),
required=False
)

def save(self, commit=True):
gallery = super().save(commit=False)
if commit:
gallery.save()

# Associa le immagini selezionate alla galleria
images = self.cleaned_data.get('images')
if images:
for image in images:
image.gallery = gallery
image.save()

return gallery
42 changes: 42 additions & 0 deletions src/website/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 4.1.7 on 2023-09-19 15:34

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Contact',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('phone', models.CharField(blank=True, max_length=100, null=True)),
('mail', models.CharField(blank=True, max_length=50, null=True)),
],
),
migrations.CreateModel(
name='Gallery_image',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('gallery_name', models.CharField(max_length=100)),
('header', models.CharField(blank=True, default='', max_length=100, null=True)),
('description', models.CharField(blank=True, default='', max_length=300, null=True)),
('img', models.ImageField(blank=True, null=True, upload_to='')),
('is_first', models.BooleanField(default=False)),
],
),
migrations.CreateModel(
name='Opening_hour',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('weekdays', models.CharField(blank=True, max_length=200, null=True)),
('weekend', models.CharField(blank=True, max_length=300, null=True)),
('closing_day', models.CharField(blank=True, max_length=200, null=True)),
],
),
]
17 changes: 17 additions & 0 deletions src/website/migrations/0002_remove_gallery_image_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.7 on 2023-09-27 10:10

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('website', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='gallery_image',
name='header',
),
]
17 changes: 17 additions & 0 deletions src/website/migrations/0003_remove_gallery_image_img.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.7 on 2023-09-28 17:33

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('website', '0002_remove_gallery_image_header'),
]

operations = [
migrations.RemoveField(
model_name='gallery_image',
name='img',
),
]
Loading

0 comments on commit 6657653

Please sign in to comment.