-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/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", "petstagram.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() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AccountsConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "petstagram.accounts" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.urls import path, include | ||
|
||
from petstagram.accounts.views import \ | ||
signup_user, signin_user, \ | ||
details_profile, delete_profile, \ | ||
edit_profile, signout_user | ||
|
||
urlpatterns = ( | ||
path("signup/", signup_user, name="signup user"), | ||
path("signin/", signin_user, name="signin user"), | ||
path("signout/", signout_user, name="signout user"), | ||
|
||
path( | ||
"profile/<int:pk>/", include([ | ||
path("", details_profile, name="details profile"), | ||
path("edit/", edit_profile, name="edit profile"), | ||
path("delete/", delete_profile, name="delete profile") | ||
]), | ||
) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django.shortcuts import render, redirect | ||
|
||
|
||
# Callables: | ||
# - all functions | ||
# - objects with overriden `__call__` method | ||
|
||
def signup_user(request): | ||
context = {} | ||
return render(request, "accounts/signup_user.html", context) | ||
|
||
|
||
def signin_user(request): | ||
context = {} | ||
|
||
return render(request, "accounts/signin_user.html", context) | ||
|
||
|
||
def signout_user(request): | ||
# signout user | ||
return redirect('index') | ||
|
||
|
||
def details_profile(request, pk): | ||
context = {} | ||
|
||
return render(request, "accounts/details_profile.html", context) | ||
|
||
|
||
def edit_profile(request, pk): | ||
context = {} | ||
|
||
return render(request, "accounts/edit_profile.html", context) | ||
|
||
|
||
def delete_profile(request, pk): | ||
context = {} | ||
return render(request, "accounts/delete_profile.html", context) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for petstagram 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", "petstagram.settings") | ||
|
||
application = get_asgi_application() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class CommonConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "petstagram.common" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Generated by Django 4.2.9 on 2024-01-24 19:44 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
initial = True | ||
|
||
dependencies = [ | ||
("photos", "0004_alter_petphoto_photo"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="PhotoLike", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"pet_photo", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
to="photos.petphoto", | ||
), | ||
), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name="PhotoComment", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("text", models.TextField(max_length=300)), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("modified_at", models.DateTimeField(auto_now=True)), | ||
( | ||
"pet_photo", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
to="photos.petphoto", | ||
), | ||
), | ||
], | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from django.db import models | ||
|
||
from petstagram.photos.models import PetPhoto | ||
|
||
|
||
class PhotoComment(models.Model): | ||
MAX_TEXT_LENGTH = 300 | ||
|
||
text = models.TextField( | ||
max_length=MAX_TEXT_LENGTH, | ||
null=False, | ||
blank=False, | ||
) | ||
|
||
created_at = models.DateTimeField( | ||
auto_now_add=True, # Done only on `create` | ||
) | ||
|
||
modified_at = models.DateTimeField( | ||
auto_now=True, # On every save | ||
) | ||
|
||
pet_photo = models.ForeignKey( | ||
PetPhoto, | ||
on_delete=models.DO_NOTHING, | ||
) | ||
|
||
# user -> ForeignKey to users | ||
|
||
|
||
class PhotoLike(models.Model): | ||
pet_photo = models.ForeignKey( | ||
PetPhoto, | ||
on_delete=models.DO_NOTHING, | ||
) | ||
|
||
# user -> ForeignKey to users |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.urls import path | ||
|
||
from petstagram.common.views import index | ||
|
||
urlpatterns = ( | ||
path("", index, name="index"), | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.shortcuts import render | ||
|
||
|
||
def index(request): | ||
context = {} | ||
return render(request, "common/index.html", context) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.contrib import admin | ||
|
||
from petstagram.pets.models import Pet | ||
|
||
|
||
# admin.site.register(Pet) | ||
|
||
@admin.register(Pet) | ||
class PetAdmin(admin.ModelAdmin): | ||
list_display = ('name', 'date_of_birth', 'slug') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class PetsConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "petstagram.pets" |