diff --git a/README.md b/README.md index a3a7888..bd71229 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,72 @@ -# Python Visual Effects 🎬✨ - -Python で作成した美しい視覚効果とアニメーションのコレクション - -## 機能 🌟 - -- **🌈 レインボーテキスト**: 文字が色とりどりに表示される効果 -- **📝 タイプライター効果**: 文字が一文字ずつゆっくり現れる演出 -- **🖍️ カラータイプライター効果**: 文字ごとに色が変わるタイプライティング -- **🔄 スピナーエフェクト**: くるくる回るスピナーアニメーション -- **💻 マトリックス風エフェクト**: 日本語文字が緑色で画面を流れる -- **💥 爆発アニメーション**: 殡階的に拡大する爆発エフェクト - -## 実行方法 🚀 - -```bash -python3 hello.py -``` - -## 必要な環境 📋 - -- Python 3.x -- ターミナル/コマンドプロンプト (カラー表示対応) - -## デモ 🎥 - -実行すると以下のエフェクトが順番に表示されます: - -1. 長文のタイプライター効果でメッセージが表示 -2. カラータイプライター効果 -3. スピナーエフェクト -4. レインボーカラーでテキストが輝く -5. 日本語文字のマトリックス風エフェクト -6. 爆発アニメーション - -## 技術詳細 🔧 - -- **カラーエフェクト**: ANSI エスケープコードを使用 -- **アニメーション**: time.sleep() による時間制御 -- **文字セット**: 日本語ひらがな + 数字の組み合わせ - -## 作成者 👨‍💻 - -Claude と協力して作成された視覚効果プロジェクト - ---- - -*美しいターミナルアートをお楽しみください!* ✨ \ No newline at end of file +# Corporate CMS + +A production-ready Corporate Content Management System built with Django. + +## Features + +- **Core Pages:** Manage static pages (About, Services, etc.) with a Rich Text Editor. +- **News/Blog:** Post company news with images, categories, and tags. +- **Contact Form:** Secure contact form with admin notification (messages saved to DB). +- **Admin Interface:** Fully customized admin dashboard for easy content management. +- **Responsive Design:** Built with Bootstrap 5. + +## Tech Stack + +- Python 3.12+ +- Django 4.2+ +- SQLite (Development) / PostgreSQL (Production ready) +- Bootstrap 5 +- Django Summernote (WYSIWYG Editor) + +## Setup Instructions + +1. **Clone the repository:** + ```bash + git clone + cd + ``` + +2. **Create a virtual environment:** + ```bash + python -m venv venv + source venv/bin/activate # On Windows: venv\Scripts\activate + ``` + +3. **Install dependencies:** + ```bash + pip install -r requirements.txt + ``` + +4. **Run Migrations:** + ```bash + python manage.py migrate + ``` + +5. **Create a Superuser:** + ```bash + python manage.py createsuperuser + ``` + +6. **Run the Server:** + ```bash + python manage.py runserver + ``` + Or use the helper script: + ```bash + ./run.sh + ``` + +## Usage + +1. Access the Admin Panel at `http://127.0.0.1:8000/admin/`. +2. Login with your superuser credentials. +3. Create Pages and News Posts. +4. View the site at `http://127.0.0.1:8000/`. + +## Production Deployment Notes + +- Set `DEBUG = False` in `config/settings.py`. +- Configure `ALLOWED_HOSTS`. +- Use a production database like PostgreSQL. +- Serve static files using Nginx/Apache. +- Use Gunicorn as the WSGI server. diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config/__pycache__/__init__.cpython-312.pyc b/config/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..3f94899 Binary files /dev/null and b/config/__pycache__/__init__.cpython-312.pyc differ diff --git a/config/__pycache__/settings.cpython-312.pyc b/config/__pycache__/settings.cpython-312.pyc new file mode 100644 index 0000000..d96af2e Binary files /dev/null and b/config/__pycache__/settings.cpython-312.pyc differ diff --git a/config/__pycache__/urls.cpython-312.pyc b/config/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000..344a7ee Binary files /dev/null and b/config/__pycache__/urls.cpython-312.pyc differ diff --git a/config/__pycache__/wsgi.cpython-312.pyc b/config/__pycache__/wsgi.cpython-312.pyc new file mode 100644 index 0000000..0255d2c Binary files /dev/null and b/config/__pycache__/wsgi.cpython-312.pyc differ diff --git a/config/asgi.py b/config/asgi.py new file mode 100644 index 0000000..87078af --- /dev/null +++ b/config/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for config project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_asgi_application() diff --git a/config/settings.py b/config/settings.py new file mode 100644 index 0000000..3fea6be --- /dev/null +++ b/config/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for config project. +""" + +from pathlib import Path +import os + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "django-insecure-6-#rm#!l-^n4l7@fiao&+qa4@mh@a1ilr#awypypf)-u%x8uli" + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['*'] + + +# Application definition + +INSTALLED_APPS = [ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "django_summernote", + "core", + "news", + "contact", +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", +] + +ROOT_URLCONF = "config.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [BASE_DIR / 'templates'], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ], + }, + }, +] + +WSGI_APPLICATION = "config.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/4.2/topics/i18n/ + +LANGUAGE_CODE = "en-us" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.2/howto/static-files/ + +STATIC_URL = "static/" +STATIC_ROOT = BASE_DIR / 'staticfiles' + +MEDIA_URL = '/media/' +MEDIA_ROOT = BASE_DIR / 'media' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +X_FRAME_OPTIONS = 'SAMEORIGIN' diff --git a/config/urls.py b/config/urls.py new file mode 100644 index 0000000..a1d9a53 --- /dev/null +++ b/config/urls.py @@ -0,0 +1,16 @@ +from django.contrib import admin +from django.urls import path, include +from django.conf import settings +from django.conf.urls.static import static + +urlpatterns = [ + path('admin/', admin.site.urls), + path('summernote/', include('django_summernote.urls')), + path('news/', include('news.urls')), + path('contact/', include('contact.urls')), + path('', include('core.urls')), +] + +if settings.DEBUG: + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/config/wsgi.py b/config/wsgi.py new file mode 100644 index 0000000..a9afbb3 --- /dev/null +++ b/config/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for config project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_wsgi_application() diff --git a/contact/__init__.py b/contact/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/contact/__pycache__/__init__.cpython-312.pyc b/contact/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..024b06c Binary files /dev/null and b/contact/__pycache__/__init__.cpython-312.pyc differ diff --git a/contact/__pycache__/admin.cpython-312.pyc b/contact/__pycache__/admin.cpython-312.pyc new file mode 100644 index 0000000..8641cec Binary files /dev/null and b/contact/__pycache__/admin.cpython-312.pyc differ diff --git a/contact/__pycache__/apps.cpython-312.pyc b/contact/__pycache__/apps.cpython-312.pyc new file mode 100644 index 0000000..c00c16b Binary files /dev/null and b/contact/__pycache__/apps.cpython-312.pyc differ diff --git a/contact/__pycache__/forms.cpython-312.pyc b/contact/__pycache__/forms.cpython-312.pyc new file mode 100644 index 0000000..d81c1c0 Binary files /dev/null and b/contact/__pycache__/forms.cpython-312.pyc differ diff --git a/contact/__pycache__/models.cpython-312.pyc b/contact/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000..edc6923 Binary files /dev/null and b/contact/__pycache__/models.cpython-312.pyc differ diff --git a/contact/__pycache__/tests.cpython-312.pyc b/contact/__pycache__/tests.cpython-312.pyc new file mode 100644 index 0000000..3a16858 Binary files /dev/null and b/contact/__pycache__/tests.cpython-312.pyc differ diff --git a/contact/__pycache__/urls.cpython-312.pyc b/contact/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000..cff18c7 Binary files /dev/null and b/contact/__pycache__/urls.cpython-312.pyc differ diff --git a/contact/__pycache__/views.cpython-312.pyc b/contact/__pycache__/views.cpython-312.pyc new file mode 100644 index 0000000..6f33357 Binary files /dev/null and b/contact/__pycache__/views.cpython-312.pyc differ diff --git a/contact/admin.py b/contact/admin.py new file mode 100644 index 0000000..040fa32 --- /dev/null +++ b/contact/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin +from .models import ContactMessage + +@admin.register(ContactMessage) +class ContactMessageAdmin(admin.ModelAdmin): + list_display = ('name', 'email', 'subject', 'created_at') + search_fields = ('name', 'email', 'subject', 'message') + readonly_fields = ('created_at',) diff --git a/contact/apps.py b/contact/apps.py new file mode 100644 index 0000000..a940689 --- /dev/null +++ b/contact/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ContactConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "contact" diff --git a/contact/forms.py b/contact/forms.py new file mode 100644 index 0000000..6f166ff --- /dev/null +++ b/contact/forms.py @@ -0,0 +1,13 @@ +from django import forms +from .models import ContactMessage + +class ContactForm(forms.ModelForm): + class Meta: + model = ContactMessage + fields = ['name', 'email', 'subject', 'message'] + widgets = { + 'name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Your Name'}), + 'email': forms.EmailInput(attrs={'class': 'form-control', 'placeholder': 'Your Email'}), + 'subject': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Subject'}), + 'message': forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Your Message'}), + } diff --git a/contact/migrations/0001_initial.py b/contact/migrations/0001_initial.py new file mode 100644 index 0000000..a34ee7b --- /dev/null +++ b/contact/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 4.2.28 on 2026-02-16 09:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="ContactMessage", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=100)), + ("email", models.EmailField(max_length=254)), + ("subject", models.CharField(max_length=200)), + ("message", models.TextField()), + ("created_at", models.DateTimeField(auto_now_add=True)), + ], + ), + ] diff --git a/contact/migrations/__init__.py b/contact/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/contact/migrations/__pycache__/0001_initial.cpython-312.pyc b/contact/migrations/__pycache__/0001_initial.cpython-312.pyc new file mode 100644 index 0000000..1cbffe9 Binary files /dev/null and b/contact/migrations/__pycache__/0001_initial.cpython-312.pyc differ diff --git a/contact/migrations/__pycache__/__init__.cpython-312.pyc b/contact/migrations/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..1322347 Binary files /dev/null and b/contact/migrations/__pycache__/__init__.cpython-312.pyc differ diff --git a/contact/models.py b/contact/models.py new file mode 100644 index 0000000..c004bf6 --- /dev/null +++ b/contact/models.py @@ -0,0 +1,11 @@ +from django.db import models + +class ContactMessage(models.Model): + name = models.CharField(max_length=100) + email = models.EmailField() + subject = models.CharField(max_length=200) + message = models.TextField() + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return f"{self.name} - {self.subject}" diff --git a/contact/tests.py b/contact/tests.py new file mode 100644 index 0000000..0f59cdf --- /dev/null +++ b/contact/tests.py @@ -0,0 +1,19 @@ +from django.test import TestCase +from django.urls import reverse +from .models import ContactMessage + +class ContactTest(TestCase): + def test_contact_page_status_code(self): + response = self.client.get(reverse('contact')) + self.assertEqual(response.status_code, 200) + + def test_contact_form_submission(self): + response = self.client.post(reverse('contact'), { + 'name': 'John Doe', + 'email': 'john@example.com', + 'subject': 'Test Subject', + 'message': 'Test Message' + }) + # Check for redirect (success) + self.assertEqual(response.status_code, 302) + self.assertTrue(ContactMessage.objects.filter(email='john@example.com').exists()) diff --git a/contact/urls.py b/contact/urls.py new file mode 100644 index 0000000..447de4e --- /dev/null +++ b/contact/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.contact_view, name='contact'), +] diff --git a/contact/views.py b/contact/views.py new file mode 100644 index 0000000..cb91d83 --- /dev/null +++ b/contact/views.py @@ -0,0 +1,15 @@ +from django.shortcuts import render, redirect +from django.contrib import messages +from .forms import ContactForm + +def contact_view(request): + if request.method == 'POST': + form = ContactForm(request.POST) + if form.is_valid(): + form.save() + messages.success(request, 'Your message has been sent successfully!') + return redirect('contact') + else: + form = ContactForm() + + return render(request, 'contact/contact.html', {'form': form}) diff --git a/core/__init__.py b/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/__pycache__/__init__.cpython-312.pyc b/core/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..4d485b4 Binary files /dev/null and b/core/__pycache__/__init__.cpython-312.pyc differ diff --git a/core/__pycache__/admin.cpython-312.pyc b/core/__pycache__/admin.cpython-312.pyc new file mode 100644 index 0000000..cf0ac29 Binary files /dev/null and b/core/__pycache__/admin.cpython-312.pyc differ diff --git a/core/__pycache__/apps.cpython-312.pyc b/core/__pycache__/apps.cpython-312.pyc new file mode 100644 index 0000000..1016207 Binary files /dev/null and b/core/__pycache__/apps.cpython-312.pyc differ diff --git a/core/__pycache__/models.cpython-312.pyc b/core/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000..7059570 Binary files /dev/null and b/core/__pycache__/models.cpython-312.pyc differ diff --git a/core/__pycache__/tests.cpython-312.pyc b/core/__pycache__/tests.cpython-312.pyc new file mode 100644 index 0000000..98c9f9e Binary files /dev/null and b/core/__pycache__/tests.cpython-312.pyc differ diff --git a/core/__pycache__/urls.cpython-312.pyc b/core/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000..2e79601 Binary files /dev/null and b/core/__pycache__/urls.cpython-312.pyc differ diff --git a/core/__pycache__/views.cpython-312.pyc b/core/__pycache__/views.cpython-312.pyc new file mode 100644 index 0000000..b7cd5e1 Binary files /dev/null and b/core/__pycache__/views.cpython-312.pyc differ diff --git a/core/admin.py b/core/admin.py new file mode 100644 index 0000000..a8e183c --- /dev/null +++ b/core/admin.py @@ -0,0 +1,10 @@ +from django.contrib import admin +from django_summernote.admin import SummernoteModelAdmin +from .models import Page + +@admin.register(Page) +class PageAdmin(SummernoteModelAdmin): + summernote_fields = ('content',) + list_display = ('title', 'slug', 'status', 'updated_at') + prepopulated_fields = {'slug': ('title',)} + search_fields = ('title', 'content') diff --git a/core/apps.py b/core/apps.py new file mode 100644 index 0000000..c0ce093 --- /dev/null +++ b/core/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class CoreConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "core" diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py new file mode 100644 index 0000000..8594443 --- /dev/null +++ b/core/migrations/0001_initial.py @@ -0,0 +1,42 @@ +# Generated by Django 4.2.28 on 2026-02-16 09:38 + +from django.db import migrations, models +import django_summernote.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="Page", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=200)), + ("slug", models.SlugField(unique=True)), + ("content", django_summernote.fields.SummernoteTextField()), + ( + "status", + models.CharField( + choices=[("draft", "Draft"), ("published", "Published")], + default="draft", + max_length=10, + ), + ), + ("meta_description", models.CharField(blank=True, max_length=160)), + ("created_at", models.DateTimeField(auto_now_add=True)), + ("updated_at", models.DateTimeField(auto_now=True)), + ], + ), + ] diff --git a/core/migrations/__init__.py b/core/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/migrations/__pycache__/0001_initial.cpython-312.pyc b/core/migrations/__pycache__/0001_initial.cpython-312.pyc new file mode 100644 index 0000000..4110a74 Binary files /dev/null and b/core/migrations/__pycache__/0001_initial.cpython-312.pyc differ diff --git a/core/migrations/__pycache__/__init__.cpython-312.pyc b/core/migrations/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..e15fd10 Binary files /dev/null and b/core/migrations/__pycache__/__init__.cpython-312.pyc differ diff --git a/core/models.py b/core/models.py new file mode 100644 index 0000000..b7c1de4 --- /dev/null +++ b/core/models.py @@ -0,0 +1,18 @@ +from django.db import models +from django_summernote.fields import SummernoteTextField + +class Page(models.Model): + STATUS_CHOICES = ( + ('draft', 'Draft'), + ('published', 'Published'), + ) + title = models.CharField(max_length=200) + slug = models.SlugField(unique=True) + content = SummernoteTextField() + status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft') + meta_description = models.CharField(max_length=160, blank=True) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + + def __str__(self): + return self.title diff --git a/core/tests.py b/core/tests.py new file mode 100644 index 0000000..039a885 --- /dev/null +++ b/core/tests.py @@ -0,0 +1,28 @@ +from django.test import TestCase +from django.urls import reverse +from .models import Page + +class PageModelTest(TestCase): + def test_string_representation(self): + page = Page(title="About Us") + self.assertEqual(str(page), "About Us") + +class PageViewTest(TestCase): + def setUp(self): + self.page = Page.objects.create( + title="About Us", + slug="about-us", + content="This is the about page.", + status="published" + ) + + def test_home_view(self): + response = self.client.get(reverse('home')) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, 'core/home.html') + + def test_page_detail_view(self): + response = self.client.get(reverse('page_detail', args=[self.page.slug])) + self.assertEqual(response.status_code, 200) + self.assertContains(response, "About Us") + self.assertContains(response, "This is the about page.") diff --git a/core/urls.py b/core/urls.py new file mode 100644 index 0000000..d897265 --- /dev/null +++ b/core/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.home, name='home'), + path('page//', views.page_detail, name='page_detail'), +] diff --git a/core/views.py b/core/views.py new file mode 100644 index 0000000..09c08b6 --- /dev/null +++ b/core/views.py @@ -0,0 +1,12 @@ +from django.shortcuts import render, get_object_or_404 +from .models import Page +from news.models import Post + +def home(request): + # Get latest 3 published posts + latest_posts = Post.objects.filter(status='published').order_by('-created_on')[:3] + return render(request, 'core/home.html', {'latest_posts': latest_posts}) + +def page_detail(request, slug): + page = get_object_or_404(Page, slug=slug, status='published') + return render(request, 'core/page_detail.html', {'page': page}) diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..ac065fc Binary files /dev/null and b/db.sqlite3 differ diff --git a/hello.py b/hello.py deleted file mode 100644 index a3eba49..0000000 --- a/hello.py +++ /dev/null @@ -1,94 +0,0 @@ -import time -import random -import os - -def rainbow_text(text): - colors = ['\033[91m', '\033[92m', '\033[93m', '\033[94m', '\033[95m', '\033[96m'] - reset = '\033[0m' - - for char in text: - color = random.choice(colors) - print(f"{color}{char}{reset}", end='', flush=True) - time.sleep(0.1) - print() - -def matrix_effect(): - chars = "01アイウエオカキクケコサシスセスミチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン" - width = 50 - - for _ in range(10): - line = "" - for _ in range(width): - line += random.choice(chars) - print(f"\033[92m{line}\033[0m") - time.sleep(0.05) - -def typewriter_effect(text, delay=0.05): - for char in text: - print(char, end='', flush=True) - time.sleep(delay) - print() - -# 文字ごとに色が変化するタイプライター効果 -def colored_typewriter_effect(text, delay=0.05): - colors = ['\033[91m', '\033[92m', '\033[93m', '\033[94m', '\033[95m', '\033[96m'] - reset = '\033[0m' - for char in text: - color = random.choice(colors) - print(f"{color}{char}{reset}", end='', flush=True) - time.sleep(delay) - print() - -# シンプルなスピナーアニメーション -def spinner_effect(duration=2): - spinner = ['|', '/', '-', '\\'] - end_time = time.time() + duration - idx = 0 - while time.time() < end_time: - print(spinner[idx % len(spinner)], end='\r', flush=True) - time.sleep(0.1) - idx += 1 - print(' ', end='\r') - -def explosion_effect(): - frames = [ - "💥", - " ✨💥✨ ", - " ⭐✨💥✨⭐ ", - " 🌟⭐✨💥✨⭐🌟 ", - " 🎆🌟⭐✨💥✨⭐🌟🎆 " - ] - - for frame in frames: - os.system('clear' if os.name == 'posix' else 'cls') - print("\n" * 10) - print(f"{' ' * 2}{frame}") - time.sleep(0.3) - -print("🎬 Claude エフェクトショー開始!") -time.sleep(1) - -print("\n📝 タイプライター効果(長文):") -long_message = ( - "Hello Claude! これはとても長い文章で、タイプライター効果が" - "どのように表示されるかを示すためのものです。ゆっくりと、しかし" - "確実に文字が表示されていきます。" -) -typewriter_effect(long_message) - -print("\n🌈 カラータイプライター効果:") -colored_typewriter_effect("Colorful typing with random hues!") - -print("\n🔄 スピナーエフェクト:") -spinner_effect() - -print("\n🌈 レインボーテキスト:") -rainbow_text("AMAZING COLORS!") - -print("\n💻 ボトリックス風エフェクト:") -matrix_effect() - -print("\n💥 爆発エフェクト:") -explosion_effect() - -print("\n✨ 完了!Claude との出会いは素晴らしい!✨") diff --git a/hello_0718.py b/hello_0718.py deleted file mode 100644 index f9ff292..0000000 --- a/hello_0718.py +++ /dev/null @@ -1,5 +0,0 @@ -def hello_0718(): - return "hello 0718" - -if __name__ == "__main__": - print(hello_0718()) \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..aabb818 --- /dev/null +++ b/manage.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" + +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == "__main__": + main() diff --git a/news/__init__.py b/news/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/news/__pycache__/__init__.cpython-312.pyc b/news/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..7a78f3d Binary files /dev/null and b/news/__pycache__/__init__.cpython-312.pyc differ diff --git a/news/__pycache__/admin.cpython-312.pyc b/news/__pycache__/admin.cpython-312.pyc new file mode 100644 index 0000000..060719e Binary files /dev/null and b/news/__pycache__/admin.cpython-312.pyc differ diff --git a/news/__pycache__/apps.cpython-312.pyc b/news/__pycache__/apps.cpython-312.pyc new file mode 100644 index 0000000..8b58197 Binary files /dev/null and b/news/__pycache__/apps.cpython-312.pyc differ diff --git a/news/__pycache__/models.cpython-312.pyc b/news/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000..b7e73c4 Binary files /dev/null and b/news/__pycache__/models.cpython-312.pyc differ diff --git a/news/__pycache__/tests.cpython-312.pyc b/news/__pycache__/tests.cpython-312.pyc new file mode 100644 index 0000000..70c4e21 Binary files /dev/null and b/news/__pycache__/tests.cpython-312.pyc differ diff --git a/news/__pycache__/urls.cpython-312.pyc b/news/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000..87d03f2 Binary files /dev/null and b/news/__pycache__/urls.cpython-312.pyc differ diff --git a/news/__pycache__/views.cpython-312.pyc b/news/__pycache__/views.cpython-312.pyc new file mode 100644 index 0000000..1beb1a5 Binary files /dev/null and b/news/__pycache__/views.cpython-312.pyc differ diff --git a/news/admin.py b/news/admin.py new file mode 100644 index 0000000..0455d82 --- /dev/null +++ b/news/admin.py @@ -0,0 +1,11 @@ +from django.contrib import admin +from django_summernote.admin import SummernoteModelAdmin +from .models import Post + +@admin.register(Post) +class PostAdmin(SummernoteModelAdmin): + summernote_fields = ('content',) + list_display = ('title', 'slug', 'status', 'created_on') + list_filter = ('status', 'created_on') + search_fields = ('title', 'content') + prepopulated_fields = {'slug': ('title',)} diff --git a/news/apps.py b/news/apps.py new file mode 100644 index 0000000..e50c454 --- /dev/null +++ b/news/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class NewsConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "news" diff --git a/news/migrations/0001_initial.py b/news/migrations/0001_initial.py new file mode 100644 index 0000000..a656a72 --- /dev/null +++ b/news/migrations/0001_initial.py @@ -0,0 +1,61 @@ +# Generated by Django 4.2.28 on 2026-02-16 09:38 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django_summernote.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name="Post", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=200)), + ("slug", models.SlugField(unique=True)), + ("updated_on", models.DateTimeField(auto_now=True)), + ("content", django_summernote.fields.SummernoteTextField()), + ("created_on", models.DateTimeField(auto_now_add=True)), + ( + "status", + models.CharField( + choices=[("draft", "Draft"), ("published", "Published")], + default="draft", + max_length=10, + ), + ), + ( + "image", + models.ImageField(blank=True, null=True, upload_to="blog_images/"), + ), + ("category", models.CharField(default="General", max_length=100)), + ( + "author", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="blog_posts", + to=settings.AUTH_USER_MODEL, + ), + ), + ], + options={ + "ordering": ["-created_on"], + }, + ), + ] diff --git a/news/migrations/__init__.py b/news/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/news/migrations/__pycache__/0001_initial.cpython-312.pyc b/news/migrations/__pycache__/0001_initial.cpython-312.pyc new file mode 100644 index 0000000..a1929ff Binary files /dev/null and b/news/migrations/__pycache__/0001_initial.cpython-312.pyc differ diff --git a/news/migrations/__pycache__/__init__.cpython-312.pyc b/news/migrations/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..97c80a5 Binary files /dev/null and b/news/migrations/__pycache__/__init__.cpython-312.pyc differ diff --git a/news/models.py b/news/models.py new file mode 100644 index 0000000..ffdab8c --- /dev/null +++ b/news/models.py @@ -0,0 +1,24 @@ +from django.db import models +from django.contrib.auth.models import User +from django_summernote.fields import SummernoteTextField + +class Post(models.Model): + STATUS_CHOICES = ( + ('draft', 'Draft'), + ('published', 'Published'), + ) + title = models.CharField(max_length=200) + slug = models.SlugField(unique=True) + author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blog_posts') + updated_on = models.DateTimeField(auto_now=True) + content = SummernoteTextField() + created_on = models.DateTimeField(auto_now_add=True) + status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft') + image = models.ImageField(upload_to='blog_images/', blank=True, null=True) + category = models.CharField(max_length=100, default='General') + + class Meta: + ordering = ['-created_on'] + + def __str__(self): + return self.title diff --git a/news/tests.py b/news/tests.py new file mode 100644 index 0000000..bba0422 --- /dev/null +++ b/news/tests.py @@ -0,0 +1,28 @@ +from django.test import TestCase +from django.urls import reverse +from django.contrib.auth.models import User +from .models import Post + +class PostModelTest(TestCase): + def setUp(self): + self.user = User.objects.create_user(username='testuser', password='password') + self.post = Post.objects.create( + title="First Post", + slug="first-post", + author=self.user, + content="This is the first post.", + status="published" + ) + + def test_string_representation(self): + self.assertEqual(str(self.post), "First Post") + + def test_post_list_view(self): + response = self.client.get(reverse('post_list')) + self.assertEqual(response.status_code, 200) + self.assertContains(response, "First Post") + + def test_post_detail_view(self): + response = self.client.get(reverse('post_detail', args=[self.post.slug])) + self.assertEqual(response.status_code, 200) + self.assertContains(response, "This is the first post.") diff --git a/news/urls.py b/news/urls.py new file mode 100644 index 0000000..cf4e9b6 --- /dev/null +++ b/news/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.post_list, name='post_list'), + path('/', views.post_detail, name='post_detail'), +] diff --git a/news/views.py b/news/views.py new file mode 100644 index 0000000..49bea8e --- /dev/null +++ b/news/views.py @@ -0,0 +1,10 @@ +from django.shortcuts import render, get_object_or_404 +from .models import Post + +def post_list(request): + posts = Post.objects.filter(status='published').order_by('-created_on') + return render(request, 'news/post_list.html', {'posts': posts}) + +def post_detail(request, slug): + post = get_object_or_404(Post, slug=slug, status='published') + return render(request, 'news/post_detail.html', {'post': post}) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..418abfc --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +django>=4.2,<5.0 +django-summernote>=0.8.20.0 +Pillow>=10.0.0 +django-environ>=0.10.0 +bleach<5.0.0 diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..2e74a5b --- /dev/null +++ b/run.sh @@ -0,0 +1,2 @@ +#!/bin/bash +python manage.py runserver 0.0.0.0:8000 diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..cc5159d --- /dev/null +++ b/templates/base.html @@ -0,0 +1,60 @@ + + + + + + {% block title %}Corporate CMS{% endblock %} + + + + {% block extra_head %}{% endblock %} + + + + + +
+ {% if messages %} + {% for message in messages %} +
+ {{ message }} +
+ {% endfor %} + {% endif %} + + {% block content %} + {% endblock %} +
+ +
+
+ © {% now "Y" %} Company Name. All Rights Reserved. +
+
+ + + + diff --git a/templates/contact/contact.html b/templates/contact/contact.html new file mode 100644 index 0000000..6578074 --- /dev/null +++ b/templates/contact/contact.html @@ -0,0 +1,51 @@ +{% extends 'base.html' %} + +{% block title %}Contact Us | Corporate CMS{% endblock %} + +{% block content %} +
+
+

Contact Us

+ +
+
+ {% csrf_token %} + +
+ + {{ form.name }} + {% if form.name.errors %} +
{{ form.name.errors }}
+ {% endif %} +
+ +
+ + {{ form.email }} + {% if form.email.errors %} +
{{ form.email.errors }}
+ {% endif %} +
+ +
+ + {{ form.subject }} + {% if form.subject.errors %} +
{{ form.subject.errors }}
+ {% endif %} +
+ +
+ + {{ form.message }} + {% if form.message.errors %} +
{{ form.message.errors }}
+ {% endif %} +
+ + +
+
+
+
+{% endblock %} diff --git a/templates/core/home.html b/templates/core/home.html new file mode 100644 index 0000000..143a5fd --- /dev/null +++ b/templates/core/home.html @@ -0,0 +1,40 @@ +{% extends 'base.html' %} + +{% block content %} +
+
+

Welcome to Our Corporate CMS

+

We provide excellent services and solutions for your business needs.

+ Contact Us +
+
+ +
+
+

Latest News

+
+ {% for post in latest_posts %} +
+
+ {% if post.image %} + {{ post.title }} + {% endif %} +
+
{{ post.title }}
+

{{ post.content|striptags|truncatewords:20 }}

+ Read more +
+ +
+
+ {% empty %} +
+

No news available yet.

+
+ {% endfor %} +
+
+
+{% endblock %} diff --git a/templates/core/page_detail.html b/templates/core/page_detail.html new file mode 100644 index 0000000..1298211 --- /dev/null +++ b/templates/core/page_detail.html @@ -0,0 +1,19 @@ +{% extends 'base.html' %} + +{% block title %}{{ page.title }} | Corporate CMS{% endblock %} + +{% block content %} +
+
+
+
+

{{ page.title }}

+
Last updated: {{ page.updated_at|date:"M d, Y" }}
+
+
+ {{ page.content|safe }} +
+
+
+
+{% endblock %} diff --git a/templates/news/post_detail.html b/templates/news/post_detail.html new file mode 100644 index 0000000..c7eee07 --- /dev/null +++ b/templates/news/post_detail.html @@ -0,0 +1,29 @@ +{% extends 'base.html' %} + +{% block title %}{{ post.title }} | Corporate CMS{% endblock %} + +{% block content %} +
+
+
+
+

{{ post.title }}

+
Posted on {{ post.created_on|date:"F d, Y" }} by {{ post.author.username }}
+ {% if post.category %} + {{ post.category }} + {% endif %} +
+ {% if post.image %} +
{{ post.title }}
+ {% endif %} +
+ {{ post.content|safe }} +
+
+ + +
+
+{% endblock %} diff --git a/templates/news/post_list.html b/templates/news/post_list.html new file mode 100644 index 0000000..1b370a8 --- /dev/null +++ b/templates/news/post_list.html @@ -0,0 +1,32 @@ +{% extends 'base.html' %} + +{% block title %}News | Corporate CMS{% endblock %} + +{% block content %} +
+
+

Company News

+
+ {% for post in posts %} +
+
+ {% if post.image %} + {{ post.title }} + {% endif %} +
+
{{ post.title }}
+
{{ post.created_on|date:"F d, Y" }} by {{ post.author.username }}
+

{{ post.content|striptags|truncatewords:30 }}

+ Read More +
+
+
+ {% empty %} +
+

No news available.

+
+ {% endfor %} +
+
+
+{% endblock %} diff --git a/test_hello_0718.py b/test_hello_0718.py deleted file mode 100644 index bf1f44a..0000000 --- a/test_hello_0718.py +++ /dev/null @@ -1,16 +0,0 @@ -import unittest -from hello_0718 import hello_0718 - -class TestHello0718(unittest.TestCase): - def test_hello_0718(self): - result = hello_0718() - self.assertEqual(result, "hello 0718") - - def test_hello_0718_output(self): - # Test that the function returns the expected string - expected = "hello 0718" - actual = hello_0718() - self.assertEqual(actual, expected) - -if __name__ == "__main__": - unittest.main() \ No newline at end of file