diff --git a/.idea/dataSources.ids b/.idea/dataSources.ids new file mode 100644 index 0000000..624ae9a --- /dev/null +++ b/.idea/dataSources.ids @@ -0,0 +1,541 @@ + + + + + + + + 1 + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + 1 + INTEGER(0,-1)|4 + + + 1 + VARCHAR(80) (0,-1)|12 + + + 1 + name + + 1 + + + id + 1 + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + group_id +permission_id + + 1 + + + id + 1 + + + 1 + group_id + 1 + 1 + ~.auth_group.#1 + no_action + no_action + + + 1 + permission_id + 1 + 1 + ~.auth_permission.#1 + no_action + no_action + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + 1 + VARCHAR(100) (0,-1)|12 + + + 1 + VARCHAR(255) (0,-1)|12 + + + content_type_id +codename + + 1 + + + id + 1 + + + 1 + content_type_id + 1 + 1 + ~.django_content_type.#1 + no_action + no_action + + + 1 + INTEGER(0,-1)|4 + + + 1 + VARCHAR(128) (0,-1)|12 + + + DATETIME(0,-1)|12 + + + 1 + BOOL(0,-1)|4 + + + 1 + VARCHAR(30) (0,-1)|12 + + + 1 + VARCHAR(30) (0,-1)|12 + + + 1 + VARCHAR(254) (0,-1)|12 + + + 1 + BOOL(0,-1)|4 + + + 1 + BOOL(0,-1)|4 + + + 1 + DATETIME(0,-1)|12 + + + 1 + VARCHAR(150) (0,-1)|12 + + + 1 + username + + 1 + + + id + 1 + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + user_id +group_id + + 1 + + + id + 1 + + + 1 + user_id + 1 + 1 + ~.auth_user.#1 + no_action + no_action + + + 1 + group_id + 1 + 1 + ~.auth_group.#1 + no_action + no_action + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + user_id +permission_id + + 1 + + + id + 1 + + + 1 + user_id + 1 + 1 + ~.auth_user.#1 + no_action + no_action + + + 1 + permission_id + 1 + 1 + ~.auth_permission.#1 + no_action + no_action + + + 1 + INTEGER(0,-1)|4 + + + TEXT(0,-1)|12 + + + 1 + VARCHAR(200) (0,-1)|12 + + + 1 + SMALLINT UNSIGNED(0,-1)|4 + + + 1 + TEXT(0,-1)|12 + + + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + 1 + DATETIME(0,-1)|12 + + + id + 1 + + + 1 + content_type_id + 1 + 1 + ~.django_content_type.#1 + no_action + no_action + + + 1 + user_id + 1 + 1 + ~.auth_user.#1 + no_action + no_action + + + 1 + INTEGER(0,-1)|4 + + + 1 + VARCHAR(100) (0,-1)|12 + + + 1 + VARCHAR(100) (0,-1)|12 + + + app_label +model + + 1 + + + id + 1 + + + 1 + INTEGER(0,-1)|4 + + + 1 + VARCHAR(255) (0,-1)|12 + + + 1 + VARCHAR(255) (0,-1)|12 + + + 1 + DATETIME(0,-1)|12 + + + id + 1 + + + 1 + VARCHAR(40) (0,-1)|12 + + + 1 + TEXT(0,-1)|12 + + + 1 + DATETIME(0,-1)|12 + + + expire_date + + 1 + + + session_key + 1 + + + 1 + INTEGER(0,-1)|4 + + + 1 + VARCHAR(255) (0,-1)|12 + + + id + 1 + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + 1 + VARCHAR(100) (0,-1)|12 + + + id + 1 + + + 1 + place_id + 1 + 1 + ~.places_place.#1 + no_action + no_action + + + 1 + INTEGER(0,-1)|4 + + + 1 + VARCHAR(255) (0,-1)|12 + + + 1 + BOOL(0,-1)|4 + + + VARCHAR(255) (0,-1)|12 + + + 1 + BOOL(0,-1)|4 + + + VARCHAR(255) (0,-1)|12 + + + TEXT(0,-1)|12 + + + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + id + 1 + + + 1 + category_id + 1 + 1 + ~.places_category.#1 + no_action + no_action + + + 1 + user_id + 1 + 1 + ~.auth_user.#1 + no_action + no_action + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + id + 1 + + + 1 + place_id + 1 + 1 + ~.places_place.#1 + no_action + no_action + + + 1 + user_id + 1 + 1 + ~.auth_user.#1 + no_action + no_action + + + 1 + INTEGER(0,-1)|4 + + + TEXT(0,-1)|12 + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + 1 + INTEGER(0,-1)|4 + + + id + 1 + + + 1 + place_id + 1 + 1 + ~.places_place.#1 + no_action + no_action + + + 1 + user_id + 1 + 1 + ~.auth_user.#1 + no_action + no_action + + + (0,-1)|12 + + + (0,-1)|12 + + + + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..d06d1d4 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,11 @@ + + + + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/db.sqlite3 + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..440153d --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..3b31283 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ee837ab --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a5c4d39 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/velespi.iml b/.idea/velespi.iml new file mode 100644 index 0000000..218dfcf --- /dev/null +++ b/.idea/velespi.iml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/places/admin.py b/places/admin.py index 58b3ed1..b93e324 100644 --- a/places/admin.py +++ b/places/admin.py @@ -4,19 +4,22 @@ Place, Category, Review, Media ) + class MediaInline(admin.TabularInline): model = Media extra = 0 + class ReviewInline(admin.TabularInline): model = Review extra = 0 + class PlaceAdmin(admin.ModelAdmin): - list_display = ('name', 'user', 'category', 'has_wifi', + list_display = ('name', 'user', 'category', 'has_wifi', 'review_count') list_editable = ('category', 'has_wifi') - actions = ('set_wifi_true', ) + actions = ('set_wifi_true',) search_fields = ('name', 'user__username') inlines = [ MediaInline, @@ -25,8 +28,10 @@ class PlaceAdmin(admin.ModelAdmin): def set_wifi_true(self, request, queryset): queryset.update(has_wifi=True) + set_wifi_true.short_description = 'Mahmut' + admin.site.register(Place, PlaceAdmin) admin.site.register(Category) admin.site.register(Review) diff --git a/places/forms.py b/places/forms.py index a68d265..b1dee80 100644 --- a/places/forms.py +++ b/places/forms.py @@ -1,51 +1,52 @@ from django.forms import ( - ModelForm, HiddenInput, ValidationError + ModelForm, HiddenInput, ValidationError ) from places.models import Place, Media, Review + class PlaceCreationForm(ModelForm): - class Meta: - model = Place - fields = ( - 'name', - 'coordinates', - 'category', - 'has_wifi', - 'telephone', - 'description', - ) - widgets = { - 'coordinates': HiddenInput - } - - def clean_coordinates(self): - coords = self.cleaned_data['coordinates'] - - try: - lat, lng = coords.split(',') - lat = float(lat) - lng = float(lng) - - if ( - lat < -90 or lat > 90 or - lng < -180 or lng > 180 - ): - raise ValidationError('Geçerli bir koordinat girin.') - - except ValueError: - raise ValidationError('Koordinat girin.') - - return coords + class Meta: + model = Place + fields = ( + 'name', + 'coordinates', + 'category', + 'has_wifi', + 'telephone', + 'description', + ) + widgets = { + 'coordinates': HiddenInput + } + + def clean_coordinates(self): + coords = self.cleaned_data['coordinates'] + + try: + lat, lng = coords.split(',') + lat = float(lat) + lng = float(lng) + + if ( + lat < -90 or lat > 90 or + lng < -180 or lng > 180 + ): + raise ValidationError('Geçerli bir koordinat girin.') + + except ValueError: + raise ValidationError('Koordinat girin.') + + return coords class MediaCreationForm(ModelForm): - class Meta: - model = Media - fields = ('image', ) + class Meta: + model = Media + fields = ('image',) class ReviewCreationForm(ModelForm): - class Meta: - model = Review - fields = ('comment', 'vote') + class Meta: + model = Review + fields = ('comment', 'vote') diff --git a/places/models.py b/places/models.py index 4d494c5..a741108 100644 --- a/places/models.py +++ b/places/models.py @@ -12,6 +12,7 @@ class Meta: def __str__(self): return smart_text(self.name) + class PlaceManager(models.Manager): def get_queryset(self): qs = super(PlaceManager, self).get_queryset() @@ -22,8 +23,9 @@ def active_places(self): is_active=True, ) + class Place(models.Model): - user = models.ForeignKey(settings.AUTH_USER_MODEL, + user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='added_places') name = models.CharField(max_length=255) is_active = models.BooleanField(default=False) @@ -48,6 +50,7 @@ def get_absolute_url(self): def review_count(self): return self.review_set.count() + class Review(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL) place = models.ForeignKey(Place) @@ -66,6 +69,7 @@ class Review(models.Model): def __str__(self): return smart_text(self.comment) + class Media(models.Model): place = models.ForeignKey(Place) image = models.ImageField(upload_to="places") diff --git a/places/views.py b/places/views.py index 7f9835c..ccc53e1 100644 --- a/places/views.py +++ b/places/views.py @@ -18,8 +18,9 @@ def index(request): } ) + def detail(request, id): - return render( + return render( request, 'place.html', { @@ -27,6 +28,7 @@ def detail(request, id): } ) + @login_required(login_url='login') def new_place(request): form = PlaceCreationForm() @@ -51,6 +53,7 @@ def new_place(request): } ) + @login_required(login_url='login') def new_media(request, place_id): place = get_object_or_404(Place, id=place_id) @@ -72,6 +75,7 @@ def new_media(request, place_id): } ) + @login_required(login_url='login') def new_review(request, place_id): place = get_object_or_404(Place, id=place_id) @@ -94,12 +98,13 @@ def new_review(request, place_id): } ) + @login_required(login_url='login') def like_place(request, place_id): place = get_object_or_404(Place, id=place_id) if request.method == "POST": - + if request.user in place.likes.all(): place.likes.remove(request.user) action = 'unlike' diff --git a/profiles/forms.py b/profiles/forms.py index d248ae9..332f6b4 100644 --- a/profiles/forms.py +++ b/profiles/forms.py @@ -7,9 +7,10 @@ class RegistrationForm(UserCreationForm): - class Meta: - fields = ['username', 'email'] - model = User + class Meta: + fields = ['username', 'email'] + model = User + class LoginForm(forms.Form): username = forms.CharField(required=True) diff --git a/profiles/views.py b/profiles/views.py index 13bf9d7..cddbccf 100644 --- a/profiles/views.py +++ b/profiles/views.py @@ -1,49 +1,57 @@ from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth import ( - login as auth_login, - logout as auth_logout + login as auth_login, + logout as auth_logout ) from profiles.forms import RegistrationForm, LoginForm + def register(request): - form = RegistrationForm() + form = RegistrationForm() + + if request.method == 'POST': + form = RegistrationForm(request.POST) - if request.method == 'POST': - form = RegistrationForm(request.POST) + if form.is_valid(): + form.save() - if form.is_valid(): - form.save() + messages.info( + request, + 'Kayıt başarılı. Şimdi login olabilirsiniz.' + ) - messages.info( - request, - 'Kayıt başarılı. Şimdi login olabilirsiniz.' - ) + return redirect('login') - return redirect('login') + return render(request, 'register.html', { + 'form': form, + }) - return render(request, 'register.html', { - 'form': form, - }) def login(request): - form = LoginForm() + if request.user.is_authenticated: + return redirect('/') # profil sayfasına yönlendirilecek + + form = LoginForm() + + if request.method == 'POST': + form = LoginForm(request.POST) + + if form.is_valid(): + auth_login(request, form.user) + messages.info( + request, + 'Giriş yaptınız.' + ) - if request.method == 'POST': - form = LoginForm(request.POST) + return redirect('/') - if form.is_valid(): - auth_login(request, form.user) - messages.info( - request, - 'Giriş yaptınız.' - ) + return render(request, 'login.html', { + 'form': form + }) - return render(request, 'login.html', { - 'form': form - }) def logout(request): - auth_logout(request) - return redirect('/') + auth_logout(request) + return redirect('/') diff --git a/static/style.css b/static/style.css index 442a9db..9433bfa 100644 --- a/static/style.css +++ b/static/style.css @@ -1,10 +1,14 @@ body { - font-family: Helvetica; + font-family: "Roboto", "Lucida Grande", "DejaVu Sans", "Bitstream Vera Sans", Verdana, Arial, sans-serif; + background-color: #f1f1f1; } .container { - width: 600px; + width: 970px; margin: auto; + box-shadow: 0 1px 4px rgba(0, 173, 239, 0.39), 0 0 20px rgba(0, 173, 239, 0.09) inset; + background-color: #ECEFF1; + padding: 12px 12px 0; } #logo { @@ -15,23 +19,25 @@ body { #logo a { display: inline-block; - padding: 20px 10px; - color: black; - font-size: 2em; - text-decoration: none; - font-weight: normal; - color: black; - border-radius: 5px; + margin: 11px 15px; +} + +.logo-img{ + width: 256px; + height: 50px; + background-size: auto; + background: url(velespii-logo.svg) no-repeat; } + .header { margin: 10px 0; overflow: hidden; } .content { - border-top: 1px solid black; - border-bottom: 1px solid black; + border-top: 1px dashed #00adef; + border-bottom: 1px dashed #00adef; padding: 30px 0; } @@ -40,15 +46,92 @@ body { } #nav { - width: 400px; + width: 65%; margin: 35px auto; float: right; text-align: center; } #nav a { - color: black; - margin: 0 10px; + color: #37474f; + background: none; + text-decoration: none; + border: none; + height: 60px; + border-radius: 40px; + font-weight: 500; + min-width: 150px; + max-width: 250px; + margin: 1em; + padding: 1em 2em; + position: relative; + z-index: 1; +} + +#nav .button, +#nav .button-alt{ + -webkit-transition: color 0.3s; + transition: color 0.3s; + -webkit-transition-timing-function: cubic-bezier(0.75, 0, 0.125, 1); + transition-timing-function: cubic-bezier(0.75, 0, 0.125, 1); +} + + +#nav ::before, +#nav ::after{ + content: ''; + z-index: -1; + border-radius: inherit; + pointer-events: none; + position: absolute; + top: 0; + left: 0; + width: 95%; + height: 95%; + -webkit-backface-visibility: hidden; + -webkit-transition: -webkit-transform 0.3s, opacity 0.3s; + transition: transform 0.3s, opacity 0.3s; + -webkit-transition-timing-function: cubic-bezier(0.75, 0, 0.125, 1); + transition-timing-function: cubic-bezier(0.75, 0, 0.125, 1); +} + +#nav ::before{ + border: 2px solid #00adef; + opacity: 0; + -webkit-transform: scale3d(1.2, 1.2, 1); + transform: scale3d(1.2, 1.2, 1); +} + +#nav .button::before { + border-color: #7986cb; +} +#nav .button-alt::before { + border-color: #3f51b5; +} +#nav ::after { + background: #fff; +} +#nav .button::after { + background: #7986cb; +} +#nav .button-alt::after { + background: #3f51b5; +} +#nav .button:hover { + color: #7986cb; +} +#nav .button-alt:hover { + color: #3f51b5; +} +#nav :hover::before { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); +} +#nav :hover::after { + opacity: 0; + -webkit-transform: scale3d(0.8, 0.8, 1); + transform: scale3d(0.8, 0.8, 1); } h3 { @@ -66,5 +149,6 @@ form label { } #map { - height: 300px; + height: 485px; + border: 1px dashed #00adef; } \ No newline at end of file diff --git a/static/velespii-icon.png b/static/velespii-icon.png new file mode 100644 index 0000000..c40f736 Binary files /dev/null and b/static/velespii-icon.png differ diff --git a/static/velespii-logo.svg b/static/velespii-logo.svg new file mode 100644 index 0000000..4d570a0 --- /dev/null +++ b/static/velespii-logo.svg @@ -0,0 +1,851 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/base.html b/templates/base.html index 09e9bdc..7ee411b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -2,42 +2,43 @@ - {% block title %}Velespi{% endblock %} - - + {% block title %}Velespi{% endblock %} + + +
- {% if messages %} -
    - {% for message in messages %} - {{ message }} - {% endfor %} -
- {% endif %} -
- - -
-
- {% block content %} - PLACEHOLDER - {% endblock %} -
-
- Linux Yaz Kampı 2016 - Django Sınıfı örnek projesidir. -
+ {% if messages %} +
    + {% for message in messages %} + {{ message }} + {% endfor %} +
+ {% endif %} +
+ + +
+
+ {% block content %} + PLACEHOLDER + {% endblock %} +
+
+ Linux Yaz Kampı 2016 - Django Sınıfı örnek projesidir. +
diff --git a/templates/index.html b/templates/index.html index 5433c4b..40a3f33 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,29 +7,29 @@ {% endblock %} {% block js %} - + map.fitBounds(featureGroup.getBounds()); + {% endblock %} diff --git a/templates/login.html b/templates/login.html index 31d9d30..4d525e7 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,11 +1,11 @@ {% extends "base.html" %} {% block content %} -

Login

+

Login

- - {% csrf_token %} - {{ form.as_p }} - - + + {% csrf_token %} + {{ form.as_p }} + + {% endblock %} diff --git a/templates/new_media.html b/templates/new_media.html index f675e23..1455349 100644 --- a/templates/new_media.html +++ b/templates/new_media.html @@ -1,11 +1,11 @@ {% extends "base.html" %} {% block content %} -

{{ place }} için yeni bir fotoğraf:

+

{{ place }} için yeni bir fotoğraf:

- - {% csrf_token %} - {{ form.as_p }} - - + + {% csrf_token %} + {{ form.as_p }} + + {% endblock %} diff --git a/templates/new_place.html b/templates/new_place.html index 59e58f3..5069b50 100644 --- a/templates/new_place.html +++ b/templates/new_place.html @@ -1,35 +1,35 @@ {% extends "base.html" %} {% block content %} -

Yeni Yer Bildirimi

- - {% csrf_token %} - {{ form.as_p }} -
- - +

Yeni Yer Bildirimi

+ + {% csrf_token %} + {{ form.as_p }} +
+ + {% endblock %} {% block js %} - + var coordinates = e.latlng.lat + ", " + e.latlng.lng; + document.getElementById('id_coordinates').value = coordinates; + }); + {% endblock %} \ No newline at end of file diff --git a/templates/new_review.html b/templates/new_review.html index 7643c53..2b17fb5 100644 --- a/templates/new_review.html +++ b/templates/new_review.html @@ -1,11 +1,11 @@ {% extends "base.html" %} {% block content %} -

{{ place }} için yeni bir yorum:

+

{{ place }} için yeni bir yorum:

- - {% csrf_token %} - {{ form.as_p }} - - + + {% csrf_token %} + {{ form.as_p }} + + {% endblock %} diff --git a/templates/place.html b/templates/place.html index 413f62d..1c639b3 100644 --- a/templates/place.html +++ b/templates/place.html @@ -7,9 +7,9 @@

{{ place.name }}

{{ place.likes.count }} kişi beğendi. {% if user in place.likes.all %} - Beğenmekten vazgeç + Beğenmekten vazgeç {% else %} - Beğen + Beğen {% endif %}

@@ -19,13 +19,13 @@

{{ place.name }}

{% if place.review_count > 0 %}

Reviews

{% for review in place.review_set.all %} -
- {{ review.comment }} - ({{ review.vote }}) - - {{ review.user.username }} - -
+
+ {{ review.comment }} + ({{ review.vote }}) + + {{ review.user.username }} + +
{% endfor %} {% endif %} @@ -46,38 +46,38 @@

Fotoğraflar

{% endblock %} {% block js %} - + if (response.action === 'like') { + $('#like').html('Beğenmekten vazgeç'); + } else { + $('#like').html('Beğen'); + } + }); + event.preventDefault(); + }); + {% endblock %} diff --git a/templates/register.html b/templates/register.html index 91ae3e1..a4ed042 100644 --- a/templates/register.html +++ b/templates/register.html @@ -1,11 +1,11 @@ {% extends "base.html" %} {% block content %} -

Register

+

Register

- - {% csrf_token %} - {{ form.as_p }} - - + + {% csrf_token %} + {{ form.as_p }} + + {% endblock %} diff --git a/velespi/urls.py b/velespi/urls.py index 25fa25f..5089ee7 100644 --- a/velespi/urls.py +++ b/velespi/urls.py @@ -42,5 +42,3 @@ 'document_root': settings.MEDIA_ROOT, }), ] - -