'email_mangler',
'wlxml.apps.WlxmlConfig',
'alerts',
+ 'team',
)
if DEBUG:
e.returnValue = "Na stronie mogą być nie zapisane zmiany.";
return "Na stronie mogą być nie zapisane zmiany.";
};
- };
+
+
+
+ };
+
+ $('body').mousemove(function(e) {
+ CurrentDocument.active = true;
+ });
+ $('body').keydown(function(e) {
+ CurrentDocument.active = true;
+ });
+
console.log("Fetching document's text");
$('#header').addClass('out-of-date');
clearInterval(revTimer);
}});
- }, 300000);
+ }, 60 * 1000);
},
failure: function() {
$('#loading-overlay').fadeOut();
this.galleryImages = [];
this.text = null;
this.has_local_changes = false;
+ this.active = true;
this._lock = -1;
this._context_lock = -1;
this._lock_count = 0;
WikiDocument.prototype.checkRevision = function(params) {
/* this doesn't modify anything, so no locks */
var self = this;
+ let active = self.active;
+ self.active = false;
$.ajax({
method: "GET",
url: reverse("ajax_document_rev", self.id),
+ data: {
+ 'a': active,
+ },
dataType: 'text',
success: function(data) {
if (data == '') {
--- /dev/null
+from django.contrib import admin
+from . import models
+
+
+@admin.register(models.Profile)
+class ProfileAdmin(admin.ModelAdmin):
+ list_display = ['user', 'presence']
+
+
+@admin.register(models.Presence)
+class ProfileAdmin(admin.ModelAdmin):
+ list_display = ['user', 'timestamp', 'active']
+
--- /dev/null
+from django.apps import AppConfig
+
+
+class TeamConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'team'
--- /dev/null
+# Generated by Django 4.0.6 on 2023-05-22 13:06
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('documents', '0008_book_legimi_id'),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Profile',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('presence', models.BooleanField()),
+ ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='Presence',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('timestamp', models.DateTimeField(auto_now_add=True, db_index=True)),
+ ('active', models.BooleanField()),
+ ('chunk', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='documents.chunk')),
+ ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+ ],
+ ),
+ ]
--- /dev/null
+from django.conf import settings
+from django.db import models
+from django.utils.timezone import now
+
+
+class Profile(models.Model):
+ user = models.OneToOneField(settings.AUTH_USER_MODEL, models.CASCADE)
+ presence = models.BooleanField()
+
+
+class Presence(models.Model):
+ user = models.ForeignKey(settings.AUTH_USER_MODEL, models.CASCADE)
+ chunk = models.ForeignKey('documents.Chunk', models.SET_NULL, blank=True, null=True)
+ timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
+ active = models.BooleanField()
+
+ @classmethod
+ def report(cls, user, chunk, active):
+ if user.is_anonymous or not hasattr(user, 'profile') or not user.profile.presence:
+ return
+ cls.objects.create(
+ user=user,
+ chunk=chunk,
+ timestamp=now(),
+ active=active
+ )
--- /dev/null
+from django.test import TestCase
+
+# Create your tests here.
--- /dev/null
+from django.shortcuts import render
+
+# Create your views here.
from time import mktime
from urllib.parse import quote
+from django.apps import apps
from django.conf import settings
from django.urls import reverse
from django import http
doc = get_object_or_404(Chunk, pk=chunk_id)
if not doc.book.accessible(request):
return HttpResponseForbidden("Not authorized.")
+ Presence = apps.get_model('team', 'Presence')
+ Presence.report(request.user, doc, request.GET.get('a') == 'true')
return http.HttpResponse(str(doc.revision()))