-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9da029
commit 58b263d
Showing
20 changed files
with
226 additions
and
44 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.0.2 on 2018-02-25 12:23 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('article', '0007_auto_20180224_0328'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='article', | ||
name='cover', | ||
field=models.ImageField(blank=True, null=True, upload_to='upload/'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.0.2 on 2018-02-25 12:27 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('article', '0008_article_cover'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='article', | ||
name='cover', | ||
field=models.ImageField(blank=True, null=True, upload_to='static/upload/'), | ||
), | ||
] |
Binary file not shown.
Binary file added
BIN
+597 Bytes
article/migrations/__pycache__/0009_auto_20180225_2027.cpython-36.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.shortcuts import render | ||
from django.http import HttpResponse,HttpResponseRedirect | ||
from django.template import RequestContext,Template,Context,loader,defaultfilters | ||
from django.shortcuts import render_to_response | ||
from article.models import * | ||
import os,random | ||
import userpage | ||
|
||
# Create your views here. | ||
|
||
def user_login(request): | ||
return { | ||
'username':request.user, | ||
} | ||
|
||
def homepage(request): | ||
|
||
if request.user.is_authenticated :# and request.user.has_perm('cmdb.permit')): | ||
username = request.user.username | ||
else: | ||
username = None | ||
|
||
imgs = os.listdir('static/upload/') | ||
cover = random.sample(imgs,1)[0] | ||
|
||
arts = Article.objects.all() | ||
secs = Section.objects.all() | ||
return render(request,'index.html',{'cover':cover,'username':username,'arts':arts,'secs':secs}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{% extends 'base.html' %} | ||
|
||
|
||
{% block banner %} | ||
<div class="banner" style="background:url(/static/upload/{{cover}}) no-repeat;background-position:center;background-size:cover;"> | ||
<div class="container"> | ||
<h1>{% if title %}{{title}}{% endif %} </h1> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
|
||
{% for i in arts %} | ||
<div class="card"> | ||
<div class="preview row"> | ||
<div class="preview-image" style="background:url({{i.cover}}) no-repeat;background-position:center;background-size:cover;"> | ||
<p></p> | ||
</div> | ||
<div class="preview-info"> | ||
<h2>{{i.title}}</h2> | ||
<p class="fad">{{i.detail|truncatewords:"30"|striptags}}</p> | ||
<span class="glyphicon glyphicon-time fad"> </span> <span class="fad">{{i.publish_time}}</span> | ||
| ||
<span class="glyphicon glyphicon-user fad"> </span> <span class="fad">{{i.author}}</span> | ||
<span class="pull-right"> | ||
<span><a href="/article/{{i.id}}/">阅读全文</a></span> | ||
</span> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
{% endfor %} | ||
|
||
{% endblock %} | ||
|
||
{% block sidebar %} | ||
|
||
<div class="card"> | ||
<h4>分类</h4> | ||
<span class="sep"></span> | ||
{% for i in secs %} | ||
<p><a href="">{{i.name}}</a></p> | ||
<span class="sep"></span> | ||
{% endfor %} | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
{% extends "base.html"%} | ||
|
||
|
||
{% if messages %} | ||
<ul class="messages"> | ||
{% for message in messages %} | ||
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
|
||
<form method="post"> | ||
{% csrf_token %} | ||
{{ user_form.as_p }} | ||
{{ profile_form.as_p }} | ||
<button type="submit">Save changes</button> | ||
</form> | ||
{% block content%} | ||
{% if messages %} | ||
<ul class="messages"> | ||
{% for message in messages %} | ||
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
|
||
<div class="card"> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{ user_form.as_p }} | ||
{{ profile_form.as_p }} | ||
<button type="submit">Save changes</button> | ||
</form> | ||
</div> | ||
{% endblock %} |