Skip to content

Commit

Permalink
Merge pull request #2 from irzaip/pengajar
Browse files Browse the repository at this point in the history
pengajar
  • Loading branch information
machineska authored Jul 5, 2021
2 parents b812b96 + e1f8b7e commit 6317294
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 14 deletions.
3 changes: 2 additions & 1 deletion edukasi/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
admin.site.register(Logakses)
admin.site.register(Review)
admin.site.register(Penyelenggara)
admin.site.register(Kegiatan)
admin.site.register(Kegiatan)
admin.site.register(Pengajar)
29 changes: 29 additions & 0 deletions edukasi/migrations/0032_auto_20210704_2009.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 3.1.2 on 2021-07-04 13:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('edukasi', '0031_auto_20210704_1017'),
]

operations = [
migrations.CreateModel(
name='Pengajar',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nama', models.CharField(max_length=200)),
('lokasi', models.CharField(max_length=200, null=True)),
('deskripsi', models.TextField()),
('bank', models.CharField(max_length=200)),
('no_akun', models.CharField(max_length=200)),
],
),
migrations.AlterField(
model_name='kegiatan',
name='url_donasi',
field=models.CharField(max_length=300, null=True),
),
]
33 changes: 33 additions & 0 deletions edukasi/migrations/0033_auto_20210704_2015.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.1.2 on 2021-07-04 13:15

import ckeditor.fields
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('edukasi', '0032_auto_20210704_2009'),
]

operations = [
migrations.RemoveField(
model_name='materi',
name='tentang_pengajar',
),
migrations.RemoveField(
model_name='pengajar',
name='deskripsi',
),
migrations.AddField(
model_name='pengajar',
name='tentang_pengajar',
field=ckeditor.fields.RichTextField(blank=True, null=True),
),
migrations.AlterField(
model_name='materi',
name='pengajar',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='edukasi.pengajar'),
),
]
20 changes: 20 additions & 0 deletions edukasi/migrations/0034_auto_20210704_2034.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.1.2 on 2021-07-04 13:34

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('edukasi', '0033_auto_20210704_2015'),
]

operations = [
migrations.AlterField(
model_name='materi',
name='pengajar',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='edukasi.pengajar'),
preserve_default=False,
),
]
19 changes: 16 additions & 3 deletions edukasi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@ def random_char(y):
return ''.join(random.choice(string.ascii_letters) for x in range(y))

# Create your models here.
class Pengajar(models.Model):
nama = models.CharField(max_length=200)
lokasi = models.CharField(max_length=200, blank=True)
tentang_pengajar = RichTextField(null=True, blank=True)
bank = models.CharField(max_length=200, blank=True)
no_akun = models.CharField(max_length=200, blank=True)

@classmethod
def create_pengajar(cls, nama, tentang_pengajar):
pengajar = cls(nama=nama, tentang_pengajar=tentang_pengajar)
return pengajar

def __str__(self):
return str(self.id)+"-"+self.nama

# Create your models here.
class UserExt(models.Model):
user = models.OneToOneField(User, null=True, on_delete=models.CASCADE)
phone = models.CharField(max_length=200)
Expand Down Expand Up @@ -51,8 +64,7 @@ class Materi(models.Model):
copywrite = RichTextField(null=True, blank=True)
harga = models.IntegerField(default=0)
discount = models.IntegerField(default=0)
pengajar = models.CharField(max_length=40, null=True, blank=True)
tentang_pengajar = RichTextField(null=True, blank=True)
pengajar = models.ForeignKey(Pengajar, on_delete=models.CASCADE, null=True, blank=True)
hidden = models.BooleanField(default=False)
featured = models.BooleanField(default=False)
frontpage = models.BooleanField(default=False)
Expand Down Expand Up @@ -338,3 +350,4 @@ class Kegiatan(models.Model):

def __str__(self):
return str(self.id)+"-"+self.judul_acara

7 changes: 7 additions & 0 deletions edukasi/templates/edukasi/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ <h1>Edukasi Alternatif</h1>
</div>
</section>


<div class="container">
<div class="row justify-content-end">
<a href="{% url 'list_kegiatan' %}" class="text-right">[Lihat semua Kegiatan]</a>
</div>
</div>

<div class="container">
<div class="row justify-content-end">
<a href="{% url 'listmateri' %}" class="text-right">[Lihat semua materi]</a>
Expand Down
44 changes: 44 additions & 0 deletions edukasi/templates/edukasi/listkegiatan.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% extends 'edukasi/main.html' %}
{% load crispy_forms_tags %}

{% block content %}

<div class="container" style="margin-top: 20px;">
<div class="row auto-mx">
<div class="col-sm-1 col-md-2"></div>
<div class="col-sm-10 col-md-8">
<div class="card text-center">
<div class="card-header">
{{ kegiatan.materi.judul }}
</div>
<div class="card-body">
<h2 class="card-title">{{ kegiatan.judul_acara }}</h2>
<p class="card-text">Penyelenggara: {{ kegiatan.penyelenggara.nama_penyelenggara }} ({{ kegiatan.penyelenggara.status }})</p>
<p class="card-text">Status acara: {{ kegiatan.status_acara }}</p>
<p class="card-text">Tanggal: {{ kegiatan.tanggal_mulai | date:"d M Y"}} s.d {{ kegiatan.tanggal_selesai | date:"d M Y" }}</p>
<p class="card-text">Deskripsi: {{ kegiatan.deskripsi | safe }}</p>
<p class="card-text btn">url donasi: {{ kegiatan.url_donasi }}</p>


</div>
<div class="card-footer">


</div>
</div>

<!-- Go to www.addthis.com/dashboard to customize your tools -->
<div class="align-content-center addthis_inline_share_toolbox"></div>



</div>
<div class="col-sm=1 col-md-2"></div>

</div>
</div>

<!-- Go to www.addthis.com/dashboard to customize your tools -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=irzaip"></script>

{% endblock %}
4 changes: 2 additions & 2 deletions edukasi/templates/edukasi/materi.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ <h2 class="card-title">{{ materi.judul }}</h2>

<hr>
Pengajar :
<strong>{{ materi.pengajar }}</strong><hr>
<strong>{{ materi.pengajar.nama }}</strong><hr>
Tentang pengajar:
{{ materi.tentang_pengajar | safe }}<br>
{{ materi.pengajar.tentang_pengajar | safe }}<br>

<hr>
<h3>Konten Materi</h3>
Expand Down
2 changes: 1 addition & 1 deletion edukasi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@
path('api/soal/<int:pk>/', apiviews.soal_apiview, name='soal_apiview'),
path('api/view_topic/<int:pk>/', apiviews.view_topic, name='view_topic'),
path('kegiatan/<str:sid>/', views.view_kegiatan, name='view_kegiatan'),

path('listkegiatan/', views.list_kegiatan, name='list_kegiatan'),
]
29 changes: 24 additions & 5 deletions edukasi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,13 @@ def logoutPage(request):
def homePage(request):
navmenu = get_user_menu(request)

kegiatans = Kegiatan.objects.all()[:4]

materis = Materi.objects.all()[:4]

playlist = Materi.objects.filter(playlist=True)

context = {'materis': materis, 'playlist': playlist}
context = {'materis': materis, 'playlist': playlist, 'kegiatans': kegiatans}
context = {**context, **navmenu}

return render(request, 'edukasi/home.html', context)
Expand Down Expand Up @@ -866,15 +868,20 @@ def ytb_playlist_confirm(request):
pendek = request.POST.get('pendek')
deskripsi = request.POST.get('deskripsi')
pengajar = request.POST.get('pengajar')
tentang_pengajar = request.POST.get('tentang_pengajar')
tentang_pengajar = '.'

ppengajar = Pengajar.objects.get(nama=pengajar)

if not ppengajar:
ppengajar = Pengajar.create_pengajar(nama=pengajar, tentang_pengajar=tentang_pengajar)
ppengajar.save()

materi = Materi.objects.create(
judul=judul,
kode=kode,
pendek=pendek,
deskripsi=deskripsi,
pengajar=pengajar,
tentang_pengajar=tentang_pengajar,
pengajar=ppengajar,
hidden=True,
playlist=True,
)
Expand Down Expand Up @@ -903,4 +910,16 @@ def view_kegiatan(request, sid):

context = {'kegiatan': kegiatan, 'materis': materis}
context = {**context, **navmenu}
return render(request, 'edukasi/kegiatan.html', context)
return render(request, 'edukasi/kegiatan.html', context)


def list_kegiatan(request):
navmenu = get_user_menu(request)

kegiatan = Kegiatan.objects.all()


context = {'kegiatan': kegiatan}
context = {**context, **navmenu}
return render(request, 'edukasi/listkegiatan.html', context)

10 changes: 8 additions & 2 deletions trampillpy/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
SECRET_KEY = 'vypic2_mg4@#os$szv0d#kcjfjaaouvllyn!3@=qmhki^#7ux^'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ['neo.trampill.com', ]
ALLOWED_HOSTS = ['neo.trampill.com', '192.168.30.50', '127.0.0.1']

USE_THOUSAND_SEPARATOR = True

THOUSAND_SEPARATOR = '\xa0'
# Application definition

INSTALLED_APPS = [
Expand Down Expand Up @@ -143,6 +145,10 @@
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
]
}

EMAIL_USE_TLS = True
Expand Down

0 comments on commit 6317294

Please sign in to comment.