Skip to content

Instantly share code, notes, and snippets.

@NickSablukov
Created April 22, 2015 21:12
Show Gist options
  • Save NickSablukov/7fc459a4186e60dad2aa to your computer and use it in GitHub Desktop.
Save NickSablukov/7fc459a4186e60dad2aa to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
<component name="DependencyValidationManager">
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectModuleManager">
<modules />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.4.0 (/usr/bin/python3.4)" project-jdk-type="Python SDK" />
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$USER_HOME$/courses/local/bin/python2.7" />
</component>
<component name="RunManager">
<list size="0" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/MyProject.iml" filepath="$PROJECT_DIR$/.idea/MyProject.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="FacetManager">
<facet type="django" name="Django">
<configuration>
<option name="rootFolder" value="$MODULE_DIR$" />
<option name="settingsModule" value="MyProject/settings.py" />
<option name="manageScript" value="manage.py" />
<option name="environment" value="&lt;map/&gt;" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Django" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/templates" />
</list>
</option>
</component>
</module>
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$USER_HOME$/courses/local/bin/python2.7" />
</component>
<component name="RunManager">
<list size="0" />
</component>
<component name="ShelveChangesManager" show_recycled="false" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<option name="number" value="Default" />
</task>
<servers />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="VcsManagerConfiguration">
<option name="myTodoPanelSettings">
<TodoPanelSettings />
</option>
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
</project>
SQLite format 3@ �4^�-��/�������&3 +" 
���d��I��3
%Asessions0001_initial2015-04-16 20:42:43.492293A IAauth0006_require_contenttypes_00022015-04-16 20:42:43.059809BKAauth0005_alter_user_last_login_null2015-04-16 20:42:42.915897@GAauth0004_alter_user_username_opts2015-04-16 20:42:42.583701CMAauth0003_alter_user_email_max_length2015-04-16 20:42:42.164501HWAauth0002_alter_permission_name_max_length2015-04-16 20:42:41.831060H%GAcontenttypes0002_remove_content_type_name2015-04-16 20:42:41.4888550%Aadmin0001_initial2015-04-16 20:42:41.045024/%Aauth0001_initial2015-04-16 20:42:40.7233627%%Acontenttypes0001_initial2015-04-16 20:42:40.391774 { ����kU;�?MyProject_news_categories5MyProject_categories -MyProject_medals !auth_group� )MyProject_news+auth_permission!3django_content_type auth_user/django_migrations
MyProject_news
bP���������������������\VP�ztPPP


  !     
    E 0������w0^0
MyProjectmedals !MyProjectcategoriesMyProjectnewssessionssession%#contenttypescontenttype authuser authgroup!authpermissionadminlogentry
F 1_1x�������MyProjectmedals
!MyProjectcategories MyProjectnewssessionssession%#contenttypescontenttype authuserauthgroup!authpermission adminlogentry ee:
e�'  AApbkdf2_sha256$20000$AJrSQCZcpxbm$S5lvTvIqUSPoAdWSXaELsiapT��' !-)5 AApbkdf2_sha256$20000$AJrSQCZcpxbm$S5lvTvIqUSPoAdWSXaELsiapTQ5FwA7oZQ7LtJIvfAw=DessanndesСаблуковНиколайDessanndes@yandea��' -)5 AApbkdf2_sha256$20000$AJrSQCZ� �' !  AApbkdf2_sha256$20000$TgL1GrIYBc8Q$vMDrmaH/t7Zts4d0vLR0MNR6hFORB8xyINYQL4w/B3U=Dessanndes2015-04-19 10:49:46.8330322015-04-22 13:56:31.847906 qCC�Cx���Y//�atabledjango_migrationsdjango_migrationsCREATE TABLE "django_migrations" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "app" varchar(255) NOT NULL, "name" varchar(255) NOT NULL, "applied" datetime NOT NULL)P++Ytablesqlite_sequencesqlite_sequenceCREATE TABLE sqlite_sequence(name,seq)?�!!�ktableauth_groupauth_group
CREATE TABLE "auth_group" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(80) NOT NULL UNIQUE)3 G!indexsqlite_autoindex_auth_group_1auth_group �8
99� tableauth_group_permissionsauth_group_permissions CREATE TABLE "auth_group_permissions" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "group_id" integer NOT NULL REFERENCES "auth_group" ("id"), "permission_id" integer NOT NULL REFERENCES "auth_permission" ("id"), UNIQUE ("group_id", "permission_id"))K _9indexsqlite_autoindex_auth_group_permissions_1auth_group_permissions ������3�--�[tableauth_user_groupsauth_user_groupsCREATE TABLE "auth_user_groups" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "user_id" integer NOT NULL REFERENCES "auth_user" ("id"), "group_id" integer NOT NULL REFERENCES "auth_group" ("id"), UNIQUE ("user_id", "group_id"))?S-indexsqlite_autoindex_auth_user_groups_1auth_user_groups ����=Пользователь1МодераторAАдминистратор
����=Пользователь1МодераторA Администратор 
 ���;M�Ayz9he81qp6fydqpu71scag1gjxpujaqvZjA4MmZiYTQ2NGRmNjNhNWI1NjA5YTBhN2NjMmU5NWJmMTcwMGFmMjp7Il9hdXRoX3VzZXJfaGFzaCI6ImMzOWY1ZjA5ZTAxYTRhZWIwYmI2NGM4YTYxYzc0NmZjM2E4NzcwYWIiLCJfYXV0aF91c2VyX2JhY2tlbmQiOiJkamFuZ28uY29udHJpYi5hdXRoLmJhY2tlbmRzLk1vZGVsQmFja2VuZCIsIl9hdXRoX3VzZXJfaWQiOiIxIn0=2015-05-06 13:56:32.002726
��#M yz9he81qp6fydqpu71scag1gjxpujaqv ##g�X�|�AAA� tableauth_user_user_permissionsauth_user_user_permissionsCREATE TABLE "auth_user_user_permissions" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "user_id" integer NOT NULL REFERENCES "auth_user" ("id"), "permission_id" integer NOT NULL REFERENCES "auth_permission" ("id"), UNIQUE ("user_id", "permission_id"))SgAindexsqlite_autoindex_auth_user_user_permissions_1auth_user_user_permissions�K9�;indexauth_group_permissions_0e939a4fauth_group_permissionsCREATE INDEX "auth_group_permissions_0e939a4f" ON "auth_group_permissions" ("group_id")�K9�Eindexauth_group_permissions_8373b171auth_group_permissionsCREATE INDEX "auth_group_permissions_8373b171" ON "auth_group_permissions" ("permission_id")�?-�!indexauth_user_groups_e8701ad4auth_user_groupsCREATE INDEX "auth_user_groups_e8701ad4" ON "auth_user_groups" ("user_id")�?-�#indexauth_user_groups_0e939a4fauth_user_groupsCREATE INDEX "auth_user_groups_0e939a4f" ON "auth_user_groups" ("group_id") 
 
 oo�u�(SA�Iindexauth_user_user_permissions_e8701ad4auth_user_user_permissionsCREATE INDEX "auth_user_user_permissions_e8701ad4" ON "auth_user_user_permissions" ("user_id")�.SA�Uindexauth_user_user_permissions_8373b171auth_user_user_permissionsCREATE INDEX "auth_user_user_permissions_8373b171" ON "auth_user_user_permissions" ("permission_id")�'--�tabledjango_admin_logdjango_admin_logCREATE TABLE "django_admin_log" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "action_time" datetime NOT NULL, "object_id" text NULL, "object_repr" varchar(200) NOT NULL, "action_flag" smallint unsigned NOT NULL, "change_message" text NOT NULL, "content_type_id" integer NULL REFERENCES "django_content_type" ("id"), "user_id" integer NOT NULL REFERENCES "auth_user" ("id"))�?-�1indexdjango_admin_log_417f1b1cdjango_admin_logCREATE INDEX "django_admin_log_417f1b1c" ON "django_admin_log" ("content_type_id")
����DessDessa ! Dessanndes



 SS��:y�?-�!indexdjango_admin_log_e8701ad4django_admin_log!CREATE INDEX "django_admin_log_e8701ad4" ON "django_admin_log" ("user_id")�h33�wtabledjango_content_typedjango_content_typeCREATE TABLE "django_content_type" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "app_label" varchar(100) NOT NULL, "model" varchar(100) NOT NULL, UNIQUE ("app_label", "model"))EY3indexsqlite_autoindex_django_content_type_1django_content_type�/ ++�tableauth_permissionauth_permission"CREATE TABLE "auth_permission" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "content_type_id" integer NOT NULL REFERENCES "django_content_type" ("id"), "codename" varchar(100) NOT NULL, "name" varchar(255) NOT NULL, UNIQUE ("content_type_id", "codename"))=!Q+indexsqlite_autoindex_auth_permission_1auth_permission#�"=+�-indexauth_permission_417f1b1cauth_permissionCREATE INDEX "auth_permission_417f1b1c" ON "auth_permission" ("content_type_id")

 
 ��Y�E��''�tableauth_userauth_userCREATE TABLE "auth_user" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "password" varchar(128) NOT NULL, "is_superuser" bool NOT NULL, "username" varchar(30) NOT NULL UNIQUE, "first_name" varchar(30) NOT NULL, "last_name" varchar(30) NOT NULL, "email" varchar(254) NOT NULL, "is_staff" bool NOT NULL, "is_active" bool NOT NULL, "date_joined" datetime NOT NULL, "last_login" datetime NULL)1(Eindexsqlite_autoindex_auth_user_1auth_user�6)))�'tabledjango_sessiondjango_sessionCREATE TABLE "django_session" ("session_key" varchar(40) NOT NULL PRIMARY KEY, "session_data" text NOT NULL, "expire_date" datetime NOT NULL);*O)indexsqlite_autoindex_django_session_1django_session|+;)�!indexdjango_session_de54fa62django_session$CREATE INDEX "django_session_de54fa62" ON "django_session" ("expire_date")
�.�-
��������p]J;)������r`���K3���'
delete_medals'
change_medals!
add_medalsE-/ delete_categories!/ change_categories ) add_categories#delete_news#change_newsadd_news)delete_session)change_session#add_session1delete_contenttype1change_contenttype+add_contenttype #delete_user #change_user add_user
%delete_group %change_groupadd_group/delete_permission/change_permission)add_permission +delete_logentry +change_logentry % add_logentry
��A 2015-05-06 13:56:32.002726 �����%прочее5математика-политика#Mпрограммирование QQ#��O1--�QtableMyProject_medalsMyProject_medals'CREATE TABLE "MyProject_medals" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(255) NOT NULL, "img" varchar(255) NOT NULL, "free" bool NOT NULL)�(255�stableMyProject_categoriesMyProject_categories%CREATE TABLE "MyProject_categories" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(255) NOT NULL)�/3))�tableMyProject_newsMyProject_news)CREATE TABLE "MyProject_news" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(20) NOT NULL, "article" text NOT NULL, "author_id" integer NOT NULL REFERENCES "auth_user" ("id"), "medal_id" integer NULL UNIQUE REFERENCES "MyProject_medals" ("id")) u�uH�bad posthttp://content.foto.mail.ru/mail/zzlom/_answers/i-3473.jpg?!mbest post
http://fkuplatoon.com/site/images/random/m12.png�олец») основал государство лесных эльфов в Лихолесье.
Толкин писал, что Амдир был убит в Войне Последнего союза в 3434 г. В. Э., в ходе Битвы при Дагорладе, где он вместе со всеми воинами, которых мог собрать, присоединился к армии Орофера. Он и его войско были отрезаны от союзников и загнаны в болото, где более половины из них, включая самого короля, погибли. Местность эта позже стала известна как Мёртвые Топи. После смерти Амдира его сын Амрот стал королём Лоринанда.
В другой версии тех же событий Толкин назвал этого же персонажа Мальгалад («золотое сияние»).�4�3
����  ����� 
�����   ����)Q���/Qs��" %/add_logentryCan add log entry( +5change_logentryCan change log entry( +5delete_logentryCan delete log entry&)1add_permissionCan add permission,/7change_permissionCan change permission,/7delete_permissionCan delete permission'add_groupCan add group"%-change_groupCan change group" %-delete_groupCan delete group
%add_userCan add user #+change_userCan change user #+delete_userCan delete user) +5add_contenttypeCan add content type/1;change_contenttypeCan change content type/1;delete_contenttypeCan delete content type � ��,Tp����l>�� #+add_sessionCan add session&)1change_sessionCan change session&)1delete_sessionCan delete session%add_newsCan add news #+change_newsCan change news #+delete_newsCan delete news\8.8.,!/7 delete_categoriesCan delete categories, /7 change_categoriesCan change categories&)1 add_categoriesCan add categories!)
add_medalsCan add medals$'/
change_medalsCan change medals$'/
delete_medalsCan delete medals U%b��U�*9Q?�QindexMyProject_news_categories_09c55841MyProject_news_categories2CREATE INDEX "MyProject_news_categories_09c55841" ON "MyProject_news_categories" ("categories_id")�$8Q?�EindexMyProject_news_categories_c660c5daMyProject_news_categories1CREATE INDEX "MyProject_news_categories_c660c5da" ON "MyProject_news_categories" ("news_id")z7;)�indexMyProject_news_4f331e2fMyProject_news0CREATE INDEX "MyProject_news_4f331e2f" ON "MyProject_news" ("author_id");4O)indexsqlite_autoindex_MyProject_news_1MyProject_news*�H5??�tableMyProject_news_categoriesMyProject_news_categories+CREATE TABLE "MyProject_news_categories" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "news_id" integer NOT NULL REFERENCES "MyProject_news" ("id"), "categories_id" integer NOT NULL REFERENCES "MyProject_categories" ("id"), UNIQUE ("news_id", "categories_id"))Q6e?indexsqlite_autoindex_MyProject_news_categories_1MyProject_news_categories,
����   
����� 
�����   �VK�m Тестовая новостьАмдир (синд. Amdir, в переводе с синдарина — «взгляд вверх», «надежда») — король эльфов во Вторую Эпоху. Упомянут только в «Неоконченных сказаниях»[2]. Амдир был эльфом-синда из Дориата, который отправился на восток, в Эриадор, после Войны Гнева. Там он стал королём государства Лоринанд (позже названного Лотлориэном), поскольку лесные эльфы, владевшие им ранее, уже не имели владык среди себя. Лоринанд располагался к югу от той области, где Орофер (отец Трандуила, короля эльфов из «Хоббита», и дед Леголаса из «Властелина �( :�:�*Y� Новость без медалькиМедальки кончились и у этой новости ее нет , как в прочем и категорий ! dfhdfhsdfhdfahdf
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MyProject.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
# coding: utf-8
from django.contrib.auth.forms import AuthenticationForm
from django.views.generic.edit import FormView
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import login
from django import forms
from MyProject import models
from django.contrib.auth.models import User
from django.contrib.auth.models import Group
class RegisterFormView(FormView):
form_class = UserCreationForm
success_url = "/login/"
template_name = "register.html"
def form_valid(self, form):
form.save()
return super(RegisterFormView, self).form_valid(form)
class LoginFormView(FormView):
form_class = AuthenticationForm
template_name = "login.html"
success_url = "/"
def form_valid(self, form):
self.user = form.get_user()
login(self.request, self.user)
return super(LoginFormView, self).form_valid(form)
class NewsEdit(forms.Form):
name = forms.CharField(label=u'Заголовок')
article = forms.CharField(label=u'Новость', widget=forms.Textarea)
categories = forms.MultipleChoiceField(choices=models.Categories.objects.values_list('id', 'name'), widget=forms.CheckboxSelectMultiple, required=False, label=u'Категории')
medal = forms.ModelChoiceField(queryset=models.Medals.objects.filter(free=1).all(), required=False, label=u'Медалька')
# coding: utf-8
from django.db import models
from django.contrib.auth.models import User
class Medals(models.Model):
name = models.CharField(max_length=255)
img = models.CharField(max_length=255)
free = models.BooleanField(default=True)
def __unicode__(self):
return self.name
class Categories(models.Model):
name = models.CharField(max_length=255)
def __unicode__(self):
return self.name
class News(models.Model):
name = models.CharField(max_length=20, verbose_name=u'Заголовок новости')
article = models.TextField(verbose_name=u'Новость')
author = models.ForeignKey(User)
medal = models.OneToOneField(Medals, blank=True, null=True)
categories = models.ManyToManyField('Categories', blank=True, null=True)
def __unicode__(self):
return self.name
"""
Django settings for MyProject project.
Generated by 'django-admin startproject' using Django 1.8.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'y83+e$b#vzpo$-yo#8g5y9(i8q&aib%cufe6b($_up%qq@q*bk'
# 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',
'MyProject'
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'MyProject.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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 = 'MyProject.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'MyProject/templates'),
)
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Главная страница</title>
<style>
p.dline {
line-height: 0.1;
}
P {
line-height: 0.2em;
}
</style>
</head>
<body background="http://static.truemediapipe.com/d/aiSjBLnd10/tsk5948jhc/images/bg.jpg">
{% for user in lol %}
<h1>{{ user }}</h1>
{% endfor %}
<table style="text-align: left; width: 100%;">
<tbody>
<tr>
<td style=" width: 15%;">
<span style="color:#ffffff;"><strong><p>МЕНЮ :</p></strong></span>
<p style="dline">
<p><a href="/" style="text-decoration: none;"> <span style="color:#e85226;"> Главная </span></a></p>
<p><a href="/news_edit" style="text-decoration: none;"> <span style="color:#e85226;"> Добавить новость </span></a></p>
</p>
</td>
<td style="vertical-align: top; text-align: center;">
<h2><span style="color:#ffffff;">MyProject</span></h2>
<span style="color:#ffffff; font-size:20px;"><p>бла бла бла и пушистые котята</p></span>
</td>
<td style="vertical-align: top; text-align: right; width: 15%;">
{% if user.username != '' %}
<span style="color:#f1f4ff;"><p>Привет, {{ user }}</p></span>
<p><a href="/logout" style="text-decoration: none;"><span style="color:#e85226;">Выход</span></a></p>
{% else %}
<p>&nbsp;</p>
<p><a href="/login" style="text-decoration: none;"><span style="color:#e85226;">Вход</span></a></p>
<p><a href="/register" style="text-decoration: none;"><span style="color:#e85226;">Регистрация</span></a></p>
{% endif %}
</td>
</tr>
</tbody>
<table border="0" cellpadding="2" cellspacing="2" height="24" style="text-align: left;" width="100%">
<tbody>
<tr>
<td style="vertical-align: top;">
{% for new in news %}
<span style="color:#e89d7e;"><p>{% if new.medal %}<img width="25" src="{{ new.medal.img }}">{% endif %} {{ new.name.title }}
{% if new.author.id == user.id %}<a href="/news_delete_{{ new.id }}" style="text-decoration: none;"><span style="color:#e85226;">Удалить</span></a>{% endif %}
</p></span>
<span style="color:#ffffff;"><small>{{ new.article }}</small></span>
<span style="color:#a3a3a3; font-size:10px;"><p>{{ new.author }}</p></span>
<span style="color:#fbd7b3; font-size:10px;"><p>{% for cat in new.categories.all %}{{ cat.name }} {% endfor %}</p></span>
<center style="color:#777777;">_______________________________________________________________________________________________________</center>
{% endfor %}
</td>
<td style="vertical-align: top;">&nbsp;</td>
</tr>
</tbody>
<center style="color:#777777;">_______________________________________________________________________________________________________</center>
</table>
</body>
</html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Авторизация</title>
<style>
p.dline {
line-height: 0.1;
}
P {
line-height: 0.2em;
}
</style>
</head>
<body background="http://static.truemediapipe.com/d/aiSjBLnd10/tsk5948jhc/images/bg.jpg">
{% for user in lol %}
<h1>{{ user }}</h1>
{% endfor %}
<table style="text-align: left; width: 100%;">
<tbody>
<tr>
<td style=" width: 15%;">
<span style="color:#ffffff;"><strong><p>МЕНЮ :</p></strong></span>
<p style="dline">
<p><a href="/" style="text-decoration: none;"> <span style="color:#e85226;"> Главная </span></a></p>
<p><a href="/news_edit" style="text-decoration: none;"> <span style="color:#e85226;"> Добавить новость </span></a></p>
</p>
</td>
<td style="vertical-align: top; text-align: center;">
<h2><span style="color:#ffffff;">MyProject</span></h2>
<span style="color:#ffffff; font-size:20px;"><p>бла бла бла и пушистые котята</p></span>
</td>
<td style="vertical-align: top; text-align: right; width: 15%;">
{% if user.username != '' %}
<span style="color:#f1f4ff;"><p>Привет, {{ user }}</p></span>
<p><a href="/logout" style="text-decoration: none;"><span style="color:#e85226;">Выход</span></a></p>
{% else %}
<p>&nbsp;</p>
<p><a href="/login" style="text-decoration: none;"><span style="color:#e85226;">Вход</span></a></p>
<p><a href="/register" style="text-decoration: none;"><span style="color:#e85226;">Регистрация</span></a></p>
{% endif %}
</td>
</tr>
</tbody>
<table border="0" cellpadding="2" cellspacing="2" height="24" style="text-align: left;" width="100%">
<tbody>
<tr>
<td valign="center" align="center">
{% if user.username != '' %}
<span style="color:#ffffff;"><label>Вы уже вошли в систему , необходимо выйти , чтобы авторизоваться</label></span>
<p><a href="/logout" style="text-decoration: none;"><span style="color:#e85226;">Выход</span></a></p>
{% else %}
<span style="color:#ffffff;"><form action="" method="post">
{% csrf_token %}
<!-- as_p для того, чтобы каждый элемент формы был с новой строки -->
{{ form.as_p }}
<button type="submit">Войти</button>
</form></span>
<span style="color:#ffffff;"><label> Авторизуясь , вы соглашаетесь с правилами , которых пока нет =(</label></span>
{% endif %}
</td>
<td style="vertical-align: top;">&nbsp;</td>
</tr>
</tbody>
<center style="color:#777777;">_______________________________________________________________________________________________________</center>
</table>
</body>
</html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Добавить новость</title>
<style>
p.dline {
line-height: 0.1;
}
P {
line-height: 0.2em;
}
</style>
</head>
<body background="http://static.truemediapipe.com/d/aiSjBLnd10/tsk5948jhc/images/bg.jpg">
{% for user in lol %}
<h1>{{ user }}</h1>
{% endfor %}
<table style="text-align: left; width: 100%;">
<tbody>
<tr>
<td style=" width: 15%;">
<span style="color:#ffffff;"><strong><p>МЕНЮ :</p></strong></span>
<p style="dline">
<p><a href="/" style="text-decoration: none;"> <span style="color:#e85226;"> Главная </span></a></p>
<p><a href="/news_edit" style="text-decoration: none;"> <span style="color:#e85226;"> Добавить новость </span></a></p>
</p>
</td>
<td style="vertical-align: top; text-align: center;">
<h2><span style="color:#ffffff;">MyProject</span></h2>
<span style="color:#ffffff; font-size:20px;"><p>бла бла бла и пушистые котята</p></span>
</td>
<td style="vertical-align: top; text-align: right; width: 15%;">
{% if user.username != '' %}
<span style="color:#f1f4ff;"><p>Привет, {{ user }}</p></span>
<p><a href="/logout" style="text-decoration: none;"><span style="color:#e85226;">Выход</span></a></p>
{% else %}
<p>&nbsp;</p>
<p><a href="/login" style="text-decoration: none;"><span style="color:#e85226;">Вход</span></a></p>
<p><a href="/register" style="text-decoration: none;"><span style="color:#e85226;">Регистрация</span></a></p>
{% endif %}
</td>
</tr>
</tbody>
<table border="0" cellpadding="2" cellspacing="2" height="24" style="text-align: left;" width="100%">
<tbody>
<tr>
<td style="vertical-align: top;">
<form action="" method="post">
{% csrf_token %}
<!-- as_p для того, чтобы каждый элемент формы был с новой строки -->
<span style="color:#ffffff;">{{ form.as_p }}</span>
<button {% if not au %}disabled{% endif %} type="submit">{% if au %}Добавить от имени {{ user }} {% else %}Необходимо авторизоваться{% endif %}</button>
</form>
</td>
<td style="vertical-align: top;">&nbsp;</td>
</tr>
</tbody>
<center style="color:#777777;">_______________________________________________________________________________________________________</center>
</table>
{{ a }}
</body>
</html>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form action="" method="post">
{% csrf_token %}
<!-- as_p для того, чтобы каждый элемент формы был с новой строки -->
{{ form.as_p }}
<button type="submit">Зарегистрироваться</button>
</form>
</body>
</html>
from django.conf.urls import url
from MyProject import forms
from MyProject import views
urlpatterns = [
# Examples:
# url(r'^$', 'MyProject.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^$', 'MyProject.views.home', name='home'),
url(r'^login/', forms.LoginFormView.as_view()),
url(r'^register/$', forms.RegisterFormView.as_view()),
url(r'^logout/$', views.LogoutView.as_view()),
url(r'^news_edit/$', 'MyProject.views.news_edit'),
url(r'^news_delete_(\w+)$', 'MyProject.views.news_delete'),
]
# coding: utf-8
from django.shortcuts import render, redirect
from MyProject import forms
from MyProject import models
from django.http import HttpResponseRedirect
from django.views.generic.base import View
from django.contrib.auth import logout
from django.contrib.auth.models import User
from django.contrib.auth.models import Group
def home(request):
context = {
'news': models.News.objects.all()
}
return render(request, 'home.html', context)
class LogoutView(View):
def get(self, request):
# Выполняем выход для пользователя, запросившего данное представление.
logout(request)
# После чего, перенаправляем пользователя на главную страницу.
return HttpResponseRedirect("/")
def news_edit(request):
context = {}
form = forms.NewsEdit(request.POST or None)
if form.is_valid():
news = models.News.objects.create(
name=form.cleaned_data['name'],
article=form.cleaned_data['article'],
author=request.user,
medal=form.cleaned_data['medal'],
)
for category_id in form.cleaned_data['categories']:
category = models.Categories.objects.get(id=category_id)
news.categories.add(category)
if news.medal:
models.Medals.objects.filter(id=news.medal.id).update(free=0)
return redirect(home)
context['form'] = form
context['au'] = request.user.is_authenticated()
return render(request, 'news_edit.html', context)
def news_delete(request, id):
if models.News.objects.get(id=id).medal:
models.Medals.objects.filter(id=models.News.objects.get(id=id).medal.id).update(free=1)
if models.News.objects.get(id=id).author.id == request.user.id:
models.News.objects.get(id=id).delete()
return redirect(home)
"""
WSGI config for MyProject 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/1.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MyProject.settings")
application = get_wsgi_application()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment